简体   繁体   中英

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: 这是用于调试和发布模式的 firebase 控制台 sha1 键

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

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 ?

添加 SHA1 后,您必须从 Google Play 重新安装您的应用。

Besides adding sha256 and SHA1 , you need to add your email in the Firebase console. See the attached image.

在此处输入图片说明

For my case I was just missing the 'Andoid Device Verification' API for my Firebase project from Google Cloud.

https://console.cloud.google.com/apis/library/androidcheck.googleapis.com?project={put_your_project_name_here}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM