我在iOS上的firebase_auth verifyPhoneNumber遇到问题。 我遵循了文档上的所有要求。 APN可以正常工作(可以接收FCM)和URL方案。但是每当调用verifyPhoneNumber时,SMS就会发送,但是自动验证不起作用。
注意:reCAPTCHA在模拟器上工作正常。另外,Android运行正常
Future<Null> handleSignInMobile(String mobileNumber) async {
var otpValidateScreen = OtpValidateScreen();
final PhoneCodeSent smsOTPSent = (String verId, [int forceCodeResend]) {
setState(() {
isLoading = false;
});
this.verificationId = verId;
var user = User(userName, userMobile, countryName, countryCode,
loginOrSignUp, verificationId, forceCodeResend, mobileNumber);
otpValidateScreen.updateUserDetails(user);
var route = new MaterialPageRoute(
builder: (BuildContext context) => otpValidateScreen,
);
Navigator.of(context).push(route);
};
print("smsOTPSent: + $smsOTPSent");
final PhoneVerificationCompleted verificationCompleted =
(FirebaseUser user) {
otpValidateScreen.phoneVCEvent(user);
};
print("verificationCompleted: + $verificationCompleted");
final PhoneVerificationFailed verificationFailed =
(AuthException exception) {
print("${exception.message}");
};
print("verificationFailed: + $verificationFailed");
final PhoneCodeAutoRetrievalTimeout retrievalTimeout =
(String verificationId) {
this.verificationId = verificationId;
};
print("retrievalTimeout: + $retrievalTimeout");
try {
await auth.verifyPhoneNumber(
phoneNumber: mobileNumber,
timeout: const Duration(seconds: 30),
verificationCompleted: verificationCompleted,
verificationFailed: verificationFailed,
codeSent: smsOTPSent,
codeAutoRetrievalTimeout: retrievalTimeout);
} catch (onError) {
setState(() {
isLoading = false;
});
print("${onError.message}");
}
}
一些输出:
flutter: smsOTPSent: + Closure: (String, [int]) => Null
flutter: verificationCompleted: + Closure: (FirebaseUser) => Null
flutter: verificationFailed: + Closure: (AuthException) => Null
flutter: retrievalTimeout: + Closure: (String) => Null
flutter: verId: + AM5PThCS_XDvaao6cXeZyhIVx7VxSS5-xxxxx....