Firebase:Flutter电话身份验证无法正常工作,并且应用程序崩溃

时间:2020-06-26 16:33:16

标签: ios firebase flutter firebase-authentication

我正在尝试使用Firebase电话身份验证,但是当我按下按钮来验证号码时,应用崩溃了,并且我收到此错误:

*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff23e3cf0e __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff50ba89b2 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff23e3cd4c +[NSException raise:format:] + 188
    3   Runner                              0x000000010e329d01 -[FIRPhoneAuthProvider verifyPhoneNumber:UIDelegate:completion:] + 193
    4   Runner                              0x000000010e8b05e0 -[FLTFirebaseAuthPlugin handleMethodCall:result:] + 17488
    5   Flutter                             0x00000001121c89df __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 104
    6   Flutter                             0x0000000112157622 _ZNK7flutter21PlatformMessageRouter21HandlePlat<…>
Lost connection to device.

我已经通过将iphone用作仿真器的方式在Firebase上启用了电话身份验证方法,这是验证身份的代码:

Future<void> verifyPhone(phoneNo) async{
final PhoneVerificationCompleted verified = (AuthCredential authResult){
  AuthService().signIn(authResult);
};

final PhoneVerificationFailed verificationFailed = (AuthException authException){
  print('${authException.message}');
};

final PhoneCodeSent smsSent= (String verId, [int forceResend]){
  this.verificationId = verId;
  setState(() {
    this.codeSent = true;
  });
};

final PhoneCodeAutoRetrievalTimeout autoTimeout = (String verId) {
  this.verificationId = verId;
};

await FirebaseAuth.instance.verifyPhoneNumber(
    phoneNumber: phoneNo,
    timeout: const Duration(seconds: 5),
    verificationCompleted: verified,
    verificationFailed: verificationFailed,
    codeSent: smsSent,
    codeAutoRetrievalTimeout: autoTimeout);
}

0 个答案:

没有答案