[英]firebase phone authentication problem in flutter
我正在使用以下代碼進行 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。
我正在使用此代碼: https : //www.c-sharpcorner.com/article/otp-authentication-in-flutter-using-firebase/
在新的 Firebase auth 版本中,他們進行了重大更改,例如用於人工驗證的 Recaptcha。它需要瀏覽器來驗證,將以下依賴項添加到您的 build.gradle 文件中
implementation 'androidx.browser:browser:1.3.0'
這將有助於 firebase 打開瀏覽器進行 reCAPTCHA 驗證。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.