简体   繁体   English

Firebase 电话验证仅在发布模式下不启动 OTP,但即使在为发布模式添加 sha1 后也可以在调试模式下工作

[英]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.不幸的是,即使我在 firebase 控制台中添加了调试和发布 sha1 密钥,它也无法在发布模式下工作。

Step 1. Coding part is here步骤 1. 编码部分在这里

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

Added all three different sha1 keys but still not working:(添加了所有三个不同的 sha1 密钥,但仍然无法正常工作:(

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.正如我所说,在调试模式下一切正常但在发布模式下,在启动 otp function 后,PhineVerificationFailed 立即出现 null 消息和 null 代码。

If still anything I missed please advice.如果还有什么我遗漏的,请指教。 Thanks all谢谢大家

Apart from SHA1 - you also need SHA256 thumbprint for release apk.除了SHA1 - 您还需要SHA256指纹才能发布 apk。
I faced similar issue for firebase google authentication.我在 firebase google 身份验证方面遇到了类似的问题。
Can you add SHA256 thumbprint to firebase project console and try again ?您可以将SHA256指纹添加到 firebase 项目控制台并重试吗?

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

Besides adding sha256 and SHA1 , you need to add your email in the Firebase console.除了添加sha256SHA1 ,您还需要在Firebase控制台中添加您的电子邮件。 See the attached image.请参阅随附的图像。

在此处输入图片说明

For my case I was just missing the 'Andoid Device Verification' API for my Firebase project from Google Cloud.对于我的情况,我只是缺少来自 Google Cloud 的 Firebase 项目的“Andoid 设备验证”API。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase recyclerview在发布模式下未显示任何值,但在调试模式下可完美运行 - Firebase recyclerview shows no values in release mode but it works perfectly in debug mode Facebook SDK在调试模式下有效,但在发布模式下无效 - Facebook SDK works in debug mode but not in release mode 应用程序在调试模式下工作,但在发布模式下不工作 - App works on Debug mode, but not work on Release mode Firebase电话身份验证在调试模式下可以正常工作,但该应用在发行时崩溃 - Firebase phone authentication is working fine in debug mode but the app is crashing in release 从 Firebase 下载文件 | 应用程序在调试但不是发布模式下工作 - Downloading files from Firebase | App works in debug but not release mode VS中的发布模式和调试模式 - Release Mode and Debug Mode in VS HttpClient在发布模式下不起作用,但在Xamarin Android中以调试模式工作 - Httpclient not works in release mode but works in debug mode in xamarin android 应用程序在发布时崩溃,但在调试模式下工作正常 - App Crashes in release but works fine in Debug mode 应用程式在Debug模式下运作良好,但在Release模式下引发编译错误 - App works well in Debug mode but raises compile error in release mode 选择“释放”模式但在调试模式下,应用崩溃 - App crashes when select Release mode but in debug mode works perfectly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM