如何使用火力基础身份验证实现重新发送 OTP



如何使用Firebase库在60秒后重新发送OTP,目前使用此
https://github.com/firebase/quickstart-js/blob/master/auth/phone-invisible.html

  1. 第一次调用此 发送 OTP

    window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('sign-in-button', { 
    }); 
    

    工作正常,它发送第一个OTP。 但是我添加了计时器,如果 60 秒交叉。 它将重新发送 OTP 按钮

    不是它不发送下一个 OTP,所以我怎么能得到那个?

  2. 在重新发送 OTP 时,单击呼叫相同

    window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('sign-in-button', { 
    });
    

得到解决方案: 在重新发送时,我们不需要调用相同的重新发送按钮单击,即

window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('sign-in-button', { });

相反,我们可以直接调用内部函数

firebase.auth().signInWithPhoneNumber(phoneNumber, appVerifier)

所以OTP将被重新发送。

最新更新