Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase phone auth not initiating OTP only in release mode but works on Debug mode even after added sha1 for release mode

Steps how I implemented.

As advised, I implemented all the way. It was quite good in debug mode. Unfortunately its not working in release mode even I added my debug and release sha1 keys in firebase console.

Step 1. Coding part is here

final PhoneVerificationCompleted verificationCompleted =
    (PhoneAuthCredential user) {
  successMessage('Your phone number verified successfully!');
  _loginNotifier.validate();
};

 final PhoneVerificationFailed verificationFailed = (FirebaseAuthException authException) {
  errorMessage('Phone number verification failed. Code: ${authException.code}. Message: ${authException.message}');
  print(
      'Phone number verification failed. Code: ${authException.code}. Message: ${authException.message}');
};

 final PhoneCodeAutoRetrievalTimeout codeAutoRetrievalTimeout =
    (String verificationId) {
  this._verificationId = verificationId;
  print("time out");
};

 firebaseAuth = FirebaseAuth.instance;
firebaseAuth.verifyPhoneNumber(
    phoneNumber: '+$_phoneWithCC',
    timeout: const Duration(seconds: 60),
    verificationCompleted: verificationCompleted,
    verificationFailed: verificationFailed,
    codeSent: codeSent,
    codeAutoRetrievalTimeout: codeAutoRetrievalTimeout);

Step 2: Here is the firebase console sha1 keys for debug and release mode

Added all three different sha1 keys but still not working:(

Error I am getting:

As I said, in debug mode all good as expected But in release mode, after initiating the otp function, immediately PhineVerificationFailed with null message and null code.

If still anything I missed please advice. Thanks all

like image 497
Muthu S Avatar asked Aug 29 '20 01:08

Muthu S


People also ask

How to enable phone authentication in the Firebase console?

For enabling Phone authentication in the Firebase console go to the Firebase Console. Now click on Go to Console option and navigate to your project. After that click on your project. You can get to see the below screen. After clicking on Authentication you will get to see the below screen.

How to get OTP from Firebase to your phone?

The first screen will be our Verification screen on which the user has to add his phone number. After adding his phone number, the user will click on the Get OTP button after that Firebase will send OTP on that number which is mentioned above.

Did you add the Sha of your release APK to Firebase?

Did you add the SHA of your release apk to firebase? Yes I added SHA-1 Key but I came to know that SHA-1 for debug and release mode are separate and this answer is solution ADD YOUR PLAYSTORE SIGNING KEY CERTIFICATES TO FIREBASE SHA1 AND SHA256 CERTIFICATES.

How do I test a phone number on Firebase?

In the Firebase console, open the Authentication section. In the Sign in method tab, enable the Phone provider if you haven't already. Open the Phone numbers for testing accordion menu. Provide the phone number you want to test, for example: +1 650-555-3434.


1 Answers

Apart from SHA1 - you also need SHA256 thumbprint for release apk.
I faced similar issue for firebase google authentication.
Can you add SHA256 thumbprint to firebase project console and try again ?

like image 68
abhijat_saxena Avatar answered Sep 28 '22 02:09

abhijat_saxena