Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何在Firebase Phone Authentication Android中重新发送短信验证?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
根据Firebase文档( https://firebase.google.com/docs/auth/android/phone-auth#send-a-verification-code-to-the-users-phone),有回调处理电话号码验证. @H_604_2@mCallBACks = new Phoneauthprovider.onVerificationStateChangedCallBACks() { @Override public void onVerificationCompleted(PhoneAuthCredential credential) { Log.d(tag,"onVerificationCompleted:" + credential); signInWithPhoneAuthCredential(credential); } @Override public void onVerificationFailed(FirebaseException E) { Log.w(tag,"onVerificationFailed",E); } @Override public void onCodeSent(String verificationId,Phoneauthprovider.ForceResendingToken token) { Log.d(tag,"onCodeSent:" + verificationId); // Save verification ID and resending token so we can use them later mVerificationId = verificationId; mResendToken = token; } };

我的问题是关于onCodeSent方法.它在这里文件上说(https://firebase.google.com/docs/reference/android/com/google/firebase/auth/PhoneAuthProvider.ForceResendingToken)

该令牌可用于强制重新发送SMS验证码.但是,在对doc进行一些研究后,我仍然不知道如何.

我想问一下如何使用此令牌重新发送短信验证?

解决方法

资料来源: Github

这是用于重新发送SMS验证的方法.

private void resendVerificationCode(String phonenumber,Phoneauthprovider.ForceResendingToken token) {
    Phoneauthprovider.geTinstance().verifyPhonenumber(
            phonenumber,// Phone number to verify
            60,// Timeout duration
            TimeUnit.SECONDS,// Unit of timeout
            this,// Activity (for callBACk binding)
            mCallBACks,// OnVerificationStateChangedCallBACks
            token);             // ForceResendingToken from callBACks
}

大佬总结

以上是大佬教程为你收集整理的如何在Firebase Phone Authentication Android中重新发送短信验证?全部内容,希望文章能够帮你解决如何在Firebase Phone Authentication Android中重新发送短信验证?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。