根据Firebase文档(
https://firebase.google.com/docs/auth/android/phone-auth#send-a-verification-code-to-the-users-phone),有回调处理电话号码验证.
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 }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。