首页 > 解决方案 > 如何在flutter中使用firebase电话身份验证中的forceResendingToken重新发送otp

问题描述

我正在寻找一种在 firebase verifyPhoneNumber 中重新发送OTP的方法。我已经浏览了有关 phoneAuth 的示例,但找不到重新发送 OTP 的方法。有一个 forceResendingToken 选项

final PhoneCodeSent codeSent =
        (String verificationId, [int forceResendingToken]) async {
      this.verificationId = verificationId;
      _smsCodeController.text = testSmsCode;
    };


await FirebaseAuth.instance.verifyPhoneNumber(
        phoneNumber: this._phone,
        codeAutoRetrievalTimeout: autoRetrieval,
        codeSent: smsCodeSent,
        forceResendingToken: ,//how to get this token
        timeout: const Duration(seconds: 40),
        verificationCompleted: verifSuccessful,
        verificationFailed: verifFailed);
  }

如何使用此令牌重新发送 OTP。

标签: firebasedartflutterfirebase-authentication

解决方案


Firebase 参考文档

获取ForceResendingTokenonCodeSent(String, PhoneAuthProvider.ForceResendingToken) callback强制在自动检索超时之前重新发送另一个验证短信。

因此,在您的情况下,这将是verifyPhoneNumber()PhoneCodeSent调用的回调。


推荐阅读