首页 > 解决方案 > Firebase 手机身份验证仅在发布模式下不启动 OTP,但即使在为发布模式添加 sha1 后也可以在调试模式下工作

问题描述

我如何实施的步骤。

按照建议,我一路实施。在调试模式下非常好。不幸的是,即使我在 Firebase 控制台中添加了我的调试和发布 sha1 键,它也不能在发布模式下工作。

Step 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);

第2步: 这是用于调试和发布模式的 firebase 控制台 sha1 键

添加了所有三个不同的 sha1 键,但仍然无法正常工作:(

我得到的错误:

正如我所说,在调试模式下一切正常但在发布模式下,启动 otp 函数后,立即 PhineVerificationFailed 并显示空消息和空代码。

如果还有什么我错过的,请指教。谢谢大家

标签: androidfirebasefluttersha1

解决方案


除了SHA1- 您还需要SHA256用于发布 apk 的指纹。
我在 firebase google 身份验证中遇到了类似的问题。
您可以将SHA256指纹添加到 firebase 项目控制台并重试吗?


推荐阅读