0

I started getting below error with Firebase Phone Authentication in my flutter app. What does error code 17499 mean? I couldn't get any info on this. Any hints to fix this? Thanks

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;
    });
}
Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
Krishna Shetty
  • 1,361
  • 4
  • 18
  • 39

1 Answers1

0

This worked from after migrating to Dart only FlutterFire initialisation method. It stopped working with manual initialisation using google-services.json.

Krishna Shetty
  • 1,361
  • 4
  • 18
  • 39