【发布时间】:2021-06-27 08:58:13
【问题描述】:
我正在尝试通过发送 OTP 并要求用户在收到该 OTP 后输入该 OTP 来验证电话号码。基于以下代码的此功能在 iOS 模拟器上运行良好,但在 Android 上运行不正常。
verifyPhoneNumber() async {
await auth.verifyPhoneNumber(
phoneNumber: '+92${widget.phoneNumber}',
verificationCompleted: (PhoneAuthCredential credential) async {
await auth.currentUser.updatePhoneNumber(credential);
},
verificationFailed: (FirebaseAuthException e) {
print(e.message);
},
codeSent: (String verificationId, int resendToken) {
setState(() {
_otpcode = verificationId;
});
},
codeAutoRetrievalTimeout: (String verificationId) {
setState(() {
_otpcode = verificationId;
});
},
);
}
为了让它在 android 上运行,我在 Firebase 控制台中添加了 SHA1 和 SHA256。我还启用了 Android DeviceCheck API。
在 android 上,当我在文本字段中输入电话号码后按下一步时,它似乎试图打开浏览器进行重新验证,但没有出现任何内容,只是移动到下一个屏幕询问 OTP。所以我假设它正在做隐形的recaptcha。
调试控制台显示以下错误:
( 9044): SafetyNet Attestation fails basic integrity.
I/zzjy ( 9044): Provider GmsCore_OpenSSL not available
W/System ( 9044): Ignoring header X-Firebase-Locale because its value was null.
E/FirebaseAuth( 9044): [GetAuthDomainTask] Error getting project config. Failed with {
E/FirebaseAuth( 9044): "error": {
E/FirebaseAuth( 9044): "code": 400,
E/FirebaseAuth( 9044): "message": "INVALID_CERT_HASH",
E/FirebaseAuth( 9044): "errors": [
E/FirebaseAuth( 9044): {
E/FirebaseAuth( 9044): "message": "INVALID_CERT_HASH",
E/FirebaseAuth( 9044): "domain": "global",
E/FirebaseAuth( 9044): "reason": "invalid"
E/FirebaseAuth( 9044): }
E/FirebaseAuth( 9044): ]
E/FirebaseAuth( 9044): }
E/FirebaseAuth( 9044): }
E/FirebaseAuth( 9044): 400
E/zzf ( 9044): Failed to get reCAPTCHA token - calling backend without app verification
W/System ( 9044): Ignoring header X-Firebase-Locale because its value was null.
E/FirebaseAuth( 9044): [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17093 null
I/flutter ( 9044): This request is missing a valid app identifier, meaning that neither SafetyNet checks nor reCAPTCHA checks succeeded. Please try again, or check the logcat for more details.
如上所述,相同的代码在 iOS 上运行良好,但出于某些奇怪的原因,在 Android 上却不行。请让我知道我可能会错过什么。谢谢。
【问题讨论】:
标签: firebase flutter firebase-authentication