skip to Main Content

This is not a duplicate question and forums have no clear answer!

I’m getting error when I want to verify my phone via firebase authentication

E/FirebaseAuth( 9898): [SmsRetrieverHelper] SMS verification code
request failed: unknown status code: 17499 Error code:39 I/flutter (
9898): An internal error has occurred. [ Error code:39 ]

what have I done:

  1. Entered sha(1-256) keys to firebase console
  2. Enabled Phone and Google in sign-in method firebse console
  3. Added google-services.json to android/app and GoogleService-Info.plist to ios/Runner
  4. Added(auto) firebase.json to core location of project
  5. Enabled Play integrity in firebase console app check, entered debug
    and release sha256 keys
  6. Enabled Blaze payment in firebase
  7. Enabled Google Play Integrity API in google cloud console
  8. Upload to play store as Internal testing
  9. Waited 1 day to avoid quota exceed and to let configs take effects

My pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter

  flutter_localizations:
    sdk: flutter
  intl: ^0.19.0
  shared_preferences: ^2.3.1
  firebase_core: ^3.3.0
  firebase_auth: ^5.1.4
  flutter_bloc: ^8.1.6
  fluttertoast: ^8.2.8
  cloud_firestore: ^5.2.1
  image_picker: ^1.1.2
  firebase_storage: ^12.1.3
  mobile_scanner: ^5.1.1
  omni_datetime_picker: ^2.0.3
  pdf: ^3.11.1
  printing: ^5.13.1
  flutter_email_sender: ^6.0.3
  pretty_qr_code: ^3.3.0
  url_launcher: ^6.3.0
  firebase_app_check: ^0.3.0+4

My project build.gradle:

buildscript {
    ext.kotlin_version = '1.9.0'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.google.gms:google-services:4.4.2"
    }
}

rootProject.buildDir = "../build"
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(":app")
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

My app build.gradle:

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
    id "com.google.gms.google-services"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    localProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    namespace "com.---.----" //I hide this here
    compileSdkVersion 34
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.---.----" //I hide this here
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 23
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
    
    signingConfigs {
        release {
            keyAlias localProperties['keyAlias']
            keyPassword localProperties['keyPassword']
            storeFile localProperties['storeFile'] ? file(localProperties['storeFile']) : null
            storePassword localProperties['storePassword']
        }
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation platform('com.google.firebase:firebase-bom:33.1.2')
    implementation 'com.google.firebase:firebase-auth'
    implementation 'com.google.firebase:firebase-appcheck-playintegrity'
}

My main.dart:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
    systemNavigationBarColor: Colors.white, // navigation bar color
    statusBarColor: Colors.white, // status bar color
    statusBarIconBrightness: Brightness.dark, // status bar icons' color
    systemNavigationBarIconBrightness:
        Brightness.light, //navigation bar icons' color
  ));
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
  await FirebaseAppCheck.instance.activate();
  runApp(const MyApp());
}

My code to verify:

void _verifyPhone(AuthVerifyPhoneEvent event, emit) async {
    await FirebaseAuth.instance.setSettings(appVerificationDisabledForTesting: false);
    await FirebaseAuth.instance.verifyPhoneNumber(
      phoneNumber: event.phone,
      verificationCompleted: (PhoneAuthCredential credential) async {
        await FirebaseAuth.instance.signInWithCredential(credential);
        _onVerificationComplete();
      },
      verificationFailed: (FirebaseAuthException e) {
        if (e.code == 'invalid-phone-number') {
          add(AuthEmitStateEvent(
              state: state.copyWith(error: "invalidPhoneNumber")));
        } else {
          ------ I get this to work ------
          print("---error:${e.message}");
          add(AuthEmitStateEvent(state: state.copyWith(error: e.message)));
        }
      },
      codeSent: (String verificationId, int? resendToken) {
        this.verificationId = verificationId;
        add(AuthEmitStateEvent(state: state.copyWith(pages: Pages.Code)));
      },
      codeAutoRetrievalTimeout: (String verificationId) {
        this.verificationId = verificationId;
      },
    );
  }

flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.0, on macOS 13.6.7 22G720 darwin-x64, locale en-KG)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] VS Code (version 1.92.1)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!

2

Answers


  1. i have the same issue. the same version of Firebase. that is in release version in Android and IOS in TestFlight

    Login or Signup to reply.
  2. I think the country is blocked, or It looks like some phone carriers(numbers providers) are blocking SMS with URLs

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search