我正在使用Firebase电话号码身份验证(SMS OTP)的Flutter应用程序上工作。它可以在Android上完美运行,但在iPhone上存在问题。我正在使用真实设备进行测试。安装应用程序后,我可以使用电话号码多次登录。但是过了一段时间,我无法使用相同的手机号码登录,它要求我正确检查该号码。 sim卡与我正在测试的手机在同一台手机上。调试时,手机登录在模拟器或真实设备中无法正常工作,因此我很难弄清这个问题。有没有人经历过这种奇怪的行为?我正在使用flutter 1.12.13 + hotfix.9和firebase_auth 0.15.3 + 1版本。任何帮助,将不胜感激。谢谢。
_verifyPhoneNumber(BuildContext context) async {
final FirebaseAuth _auth = FirebaseAuth.instance;
await _auth.verifyPhoneNumber(
phoneNumber: phoneNumber,
timeout: Duration(seconds: 0),
verificationCompleted: (authCredential) =>
_verificationComplete(authCredential, context),
verificationFailed: (authException) =>
_verificationFailed(authException, context),
codeAutoRetrievalTimeout: (verificationId) =>
_codeAutoRetrievalTimeout(verificationId),
// called when the SMS code is sent
codeSent: (verificationId, [code]) =>
_smsCodeSent(verificationId, [code])); }
_verificationComplete(AuthCredential authCredential, BuildContext context) {
FirebaseAuth.instance.signInWithCredential(authCredential);
if (!smsCodeSent) handleLogin(authCredential);}
_verificationFailed(AuthException authException, BuildContext context) {
showDialog(
context: context,
builder: (_) => AnimatedDialog(), // SHows diaglog box with check your number error message);}
_smsCodeSent(String verificationId, List<int> code) {
smsCodeSent = true;
_smsVerificationCode = verificationId;
smsOTPDialog(context) }
_codeAutoRetrievalTimeout(String verificationId) {
// set the verification code so that we can use it to log the user in
_smsVerificationCode = verificationId;}
smsOTPDialog(BuildContext context) {
Navigator.of(context).push(
_createRoute(userPhoneNumber, _smsVerificationCode, _fullname.text));}
答案 0 :(得分:1)
您应该在电话身份验证签名方法中获取您的号码设置,作为测试电话号码。当Firebase Auth检测到您的电话号码反复呼叫服务时,它将阻止您的电话号码使用服务。他们标记了它然后将其阻止了将近4个小时。对于每个电话号码,电话身份验证的速率限制为每小时大约5个呼叫。
尝试检查一下。