JAVA- Firebase电话身份验证错误:SMS代码已过期

问题描述

我在android java中使用phonenumber做firebaseauth。

@Override
        public void onVerificationCompleted(PhoneAuthCredential credential) {
            // This callback will be invoked in two situations:
   
            // [START_EXCLUDE silent]
            mVerificationInProgress = false;
            // [END_EXCLUDE]
            signInWithPhoneAuthCredential(credential);
        }

        @Override
        public void onVerificationFailed(FirebaseException e) {
            // This callback is invoked in an invalid request for verification is made,// for instance if the the phone number format is not valid.
            // [START_EXCLUDE silent]
            mVerificationInProgress = false;
            // [END_EXCLUDE]

            if (e instanceof FirebaseAuthInvalidCredentialsException) {
                // Invalid request

            } else if (e instanceof FirebasetooManyRequestsException) {
                
                // [END_EXCLUDE]
            }

        
        }


        @Override
        public void onCodeSent(@NonNull String verificationId,@NonNull PhoneAuthProvider.ForceResendingToken token) {
           
            // Save verification ID and resending token so we can use them later
            mVerificationId = verificationId;
            mResendToken = token;
//and do the signinwithcredential here using PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId,code);



        }

我愿意

// Firebase Authentication
@Override
public void onStart() {
    super.onStart();
    // Check if user is signed in (non-null) and update UI accordingly.
    FirebaseUser currentUser = mAuth.getCurrentUser();
    if (mVerificationInProgress && validatePhoneNumber(phoneNumber)) {
        startPhoneNumberVerification(phoneNumber);
    }
}

但是问题是 有时,它说我何时使用短信代码登录

Firebase Phone Authentication Error: The SMS Code Has Expired

我使用了相同的电话号码,有一天可以正常使用,而另一天则不能。 发生这种情况时,我会稍等片刻,然后重试,它可以正常工作。

我可以获得任何帮助吗?

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)