android - 颤振中的firebase电话身份验证问题
问题描述
我正在使用以下代码进行 Firebase 身份验证。
void NavigateToOtp(){
//Navigate to another screen
}
Future<void> verifyPhone() async {
final PhoneCodeSent smsOTPSent = (String verId, [int forceCodeResend]) {
this.verificationId = verId;
};
try {
await _auth.verifyPhoneNumber(
phoneNumber: '+XX XXXXXXXXXX', // PHONE NUMBER TO SEND OTP
codeAutoRetrievalTimeout: (String verId) {
//Starts the phone number verification process for the given phone number.
//Either sends an SMS with a 6 digit code to the phone number specified, or sign's the user in and [verificationCompleted] is called.
this.verificationId = verId;
},
codeSent:
smsOTPSent, // WHEN CODE SENT THEN WE OPEN DIALOG TO ENTER OTP.
timeout: const Duration(seconds: 20),
verificationCompleted: (AuthCredential phoneAuthCredential) {
print(_auth.currentUser());
print(phoneAuthCredential);
NavigateToOtp();
},
verificationFailed: (AuthException exceptio) {
print('${exceptio.message}');
});
} catch (e) {
handleError(e);
}
}
void sendOtp(){
verifyPhone();
}
但是向我显示以下错误:
[FirebaseAuth: ] getGoogleApiForMethod() 返回 Gms: com.google.firebase.auth.api.internal.zzaq@847da6d
我正在使用 Android 模拟器 Pixel API 29。
- 在 Google 签名中添加电话号码并在 Firebase 控制台中启用电话登录提供商
- 还创建了 SHA 密钥并在 .gradle 文件中添加了 google firebase 插件
我正在使用此代码:https ://www.c-sharpcorner.com/article/otp-authentication-in-flutter-using-firebase/
解决方案
在新的 Firebase 身份验证版本中,他们进行了重大更改,例如用于人工验证的 Recaptcha。它需要一个浏览器来验证,因此,将以下依赖项添加到您的 build.gradle 文件中
implementation 'androidx.browser:browser:1.3.0'
这将有助于 firebase 打开浏览器进行 reCAPTCHA 验证。
推荐阅读
- javascript - 对 Monaco 编辑器的缩进 SASS 支持
- oracle - Oracle 中的 CSV 文件生成
- reactjs - 在 React Router 中使用“children”元素与使用“render”函数有什么不同?
- time-series - 预测销售额
- excel - excel - 根据单元格值过滤数据透视表
- node.js - mongodb 聚合管道中的 $match 阶段不起作用
- javascript - 根据复选框选择过滤行
- javascript - 在没有 tabBarVisible 选项的情况下从 Stack Navigator 隐藏标签栏
- multithreading - 可以在 MTA 线程中使用 WaitForSingleObject/WaitForMultipleObjects 吗?
- c# - Microsoft.AnalysisServices.AdomdClient 在 .Net Core 应用程序中不起作用(身份验证问题)