I have added firebase
phone auth to my android project. First everything goes fine. After sometime, the sms code in onVerificationCompleted()
is null.Thanks!!
PhoneAuthProvider.getInstance().verifyPhoneNumber(mobileNumber, 60, TimeUnit.SECONDS, FirebasePhoneAuthActivity.this, new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
smsCode = phoneAuthCredential.getSmsCode();
Log.i(TAG, "onVerificationCompleted: CODE " + smsCode);
Log.i(TAG, "onVerificationCompleted: PROVIDER " + phoneAuthCredential.getProvider());
}
@Override
public void onVerificationFailed(FirebaseException e) {
e.printStackTrace();
}
@Override
public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
Log.i(TAG, "onCodeSent: CODE " + s);
}
@Override
public void onCodeAutoRetrievalTimeOut(String s) {
super.onCodeAutoRetrievalTimeOut(s);
Log.i(TAG, "onCodeAutoRetrievalTimeOut: " + s);
}
});
This is Instant Verification. In the official docs, it says:
Instant verification: in some cases the phone number can be instantly verified without needing to send or enter a verification code.
Also, if you look at the open-sourced FirebaseUI for Android, on this line of code it suggests that there is a possibility of verification being a success, while sms code being absent. Such a case would denote Instant Verification. So you can safely continue to use this credential to sign the user in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With