【发布时间】:2020-12-17 21:54:51
【问题描述】:
我如何实施的步骤。
按照建议,我一路实施。在调试模式下非常好。不幸的是,即使我在 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);
添加了所有三个不同的 sha1 密钥,但仍然无法正常工作:(
我遇到的错误:
正如我所说,在调试模式下一切正常 但是在release模式下,启动otp函数后,立即PhineVerificationFailed with null message and null code。
如果还有什么我错过的,请指教。谢谢大家
【问题讨论】:
-
那么你可以在添加 sha1 后尝试下载新的 google-services.json 并用旧的替换它吗?
-
是的@KrishBhanushali 我做到了.. 如此连线:(
-
在发布模式下,我立即被调用验证失败函数。我的错,verificationFailed 函数的数据为 null :(
-
keytool -list -v -keystore PATH_JKS_FILE -alias XXX 这就是我获得发布 SHA1 密钥的方式 -FYI
-
@MuthuS 您是否在清单文件中添加了 Internet 权限?这解决了我在发布模式下的问题。
标签: android firebase flutter sha1