无法在Flutter中处理updatePhoneNumberCredential异常Firebase身份验证

时间:2020-03-11 17:57:34

标签: firebase flutter firebase-authentication

当我尝试使用正确的SMS代码更新用户的电话号码时,我已经登录了用户,它可以正常工作。万一这是一个不正确的代码,我会收到一个异常,说明我无法使用常规catch或PlatformException catch处理它。

例外:

发生异常。 PlatformException (PlatformException(ERROR_INVALID_VERIFICATION_CODE,短信 用于创建电话身份验证凭证的验证码无效。 请重新发送验证码短信,并确保使用 用户提供的验证码。,空))

verifySMSCode(smsCode) async {
    final AuthCredential credential = PhoneAuthProvider.getCredential(
      verificationId: this._verificationId,
      smsCode: smsCode,
    );
    try {

      await authUser.updatePhoneNumberCredential(credential);
      await authUser.reload();

    } on PlatformException catch (err) {
      // Handle err
    } catch (err) {
      // other types of Exceptions
    }
  }

是错误还是做错了?

0 个答案:

没有答案