如何在flutter中使用Firebase电话auth中的forceResendingToken重新发送OTP

时间:2019-01-06 12:40:54

标签: firebase dart flutter firebase-authentication

我正在寻找一种重新发送Firebase verifyPhoneNumber中的 OTP 的方法。 我已完成关于example的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。

1 个答案:

答案 0 :(得分:0)

来自Firebase reference documentation

  

onCodeSent(String, PhoneAuthProvider.ForceResendingToken) callback获得的ForceResendingToken强制在自动检索超时之前重新发送另一个验证SMS。

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