FirebaseAuth phone 身份验证错误,错误代码 17499
FirebaseAuth phone authentication error, error code 17499
我开始在我的 flutter 应用程序中使用 Firebase Phone 身份验证时遇到以下错误。错误代码 17499 是什么意思?我无法获得有关此的任何信息。有什么提示可以解决这个问题吗?谢谢
E/FirebaseAuth(20851): [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17499 Requests from this Android client application xx.xxxxx.xxxxxxx are blocked.
E/flutter (20851): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'Null' is not a subtype of type 'String'
E/flutter (20851): #0 MethodChannelFirebaseAuth.verifyPhoneNumber.<anonymous closure>
@action
Future<void> getCodeWithPhoneNumber(
BuildContext context, String phoneNumber) async {
isLoginLoading = true;
await _auth.verifyPhoneNumber(
phoneNumber: phoneNumber,
timeout: const Duration(seconds: 60),
verificationCompleted: (AuthCredential auth) async {
await _auth.signInWithCredential(auth).then((UserCredential value) {
if (value != null && value.user != null) {
print('Authentication successful');
onAuthenticationSuccessful(context, value);
} else {
loginScaffoldKey.currentState!.showSnackBar(SnackBar(
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.red,
content: Text(
'Invalid code/invalid authentication',
style: TextStyle(color: Colors.white),
),
));
}
}).catchError((error) {
print(error.toString());
loginScaffoldKey.currentState!.showSnackBar(SnackBar(
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.red,
content: Text(
'Something has gone wrong, please try later',
style: TextStyle(color: Colors.white),
),
));
});
},
verificationFailed: (FirebaseAuthException authException) {
if(authException != null && authException.message != null){
print('Error message: ' + authException.message!);
loginScaffoldKey.currentState!.showSnackBar(SnackBar(
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.red,
content: Text(
authException.message!,
style: TextStyle(color: Colors.white),
), //Please enter your number in E.164 format.
));
isLoginLoading = false;
//Text(authException.message+' The phone number format is incorrect. [+][country code][number]'
}
},
codeSent: (String verificationId, [int? forceResendingToken]) async {
actualCode = verificationId;
isLoginLoading = false;
await Navigator.of(context)
.push(MaterialPageRoute(builder: (_) => const OtpPage()));
},
codeAutoRetrievalTimeout: (String verificationId) {
actualCode = verificationId;
});
}
这在迁移到 Dart only FlutterFire initialisation 方法后有效。
它停止使用 google-services.json.
进行手动初始化
我开始在我的 flutter 应用程序中使用 Firebase Phone 身份验证时遇到以下错误。错误代码 17499 是什么意思?我无法获得有关此的任何信息。有什么提示可以解决这个问题吗?谢谢
E/FirebaseAuth(20851): [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17499 Requests from this Android client application xx.xxxxx.xxxxxxx are blocked.
E/flutter (20851): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'Null' is not a subtype of type 'String'
E/flutter (20851): #0 MethodChannelFirebaseAuth.verifyPhoneNumber.<anonymous closure>
@action
Future<void> getCodeWithPhoneNumber(
BuildContext context, String phoneNumber) async {
isLoginLoading = true;
await _auth.verifyPhoneNumber(
phoneNumber: phoneNumber,
timeout: const Duration(seconds: 60),
verificationCompleted: (AuthCredential auth) async {
await _auth.signInWithCredential(auth).then((UserCredential value) {
if (value != null && value.user != null) {
print('Authentication successful');
onAuthenticationSuccessful(context, value);
} else {
loginScaffoldKey.currentState!.showSnackBar(SnackBar(
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.red,
content: Text(
'Invalid code/invalid authentication',
style: TextStyle(color: Colors.white),
),
));
}
}).catchError((error) {
print(error.toString());
loginScaffoldKey.currentState!.showSnackBar(SnackBar(
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.red,
content: Text(
'Something has gone wrong, please try later',
style: TextStyle(color: Colors.white),
),
));
});
},
verificationFailed: (FirebaseAuthException authException) {
if(authException != null && authException.message != null){
print('Error message: ' + authException.message!);
loginScaffoldKey.currentState!.showSnackBar(SnackBar(
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.red,
content: Text(
authException.message!,
style: TextStyle(color: Colors.white),
), //Please enter your number in E.164 format.
));
isLoginLoading = false;
//Text(authException.message+' The phone number format is incorrect. [+][country code][number]'
}
},
codeSent: (String verificationId, [int? forceResendingToken]) async {
actualCode = verificationId;
isLoginLoading = false;
await Navigator.of(context)
.push(MaterialPageRoute(builder: (_) => const OtpPage()));
},
codeAutoRetrievalTimeout: (String verificationId) {
actualCode = verificationId;
});
}
这在迁移到 Dart only FlutterFire initialisation 方法后有效。 它停止使用 google-services.json.
进行手动初始化