Skip to content

[firebase_app_check]: On iOS with Flutter 3.50, activate() has no effect because firebase_core now registers before firebase_app_check #18966

Closed

Description

@DouglasOGarrido

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

App Check, Core

Which platforms are affected?

iOS

Description

After upgrading from Flutter 3.47.x to 3.50.0, without changing any Dart or native code, FirebaseAppCheck.instance.activate(...) no longer takes effect on iOS. The native App Check SDK keeps the provider from its default factory instead of the one passed to activate():

  • On the simulator, AppleDebugProvider(debugToken: '<registered token>') is ignored. The SDK logs a newly generated random debug token, the exchange fails with 403 "App attestation failed.", and every request that needs App Check is rejected.
  • On a physical device the default factory picks DeviceCheck. If App Attest was requested, it is never used. When only App Attest is registered in the Firebase console, App Check fails for every user.

Android is not affected.

Root cause (as far as I can tell):

  1. Flutter 3.50 now orders the generated plugin registrant by dependency (sortByDependencies in packages/flutter_tools/lib/src/flutter_plugins.dart). Up to 3.47.x it was alphabetical. The generated ios/Runner/GeneratedPluginRegistrant.m changed like this:

    Flutter 3.47.9:

    [FirebaseAppCheckPlugin registerWithRegistrar:...];
    [FLTFirebaseCorePlugin registerWithRegistrar:...];
    

    Flutter 3.50.0:

    [FLTFirebaseCorePlugin registerWithRegistrar:...];
    ...
    [FirebaseAppCheckPlugin registerWithRegistrar:...];
    
  2. When FLTFirebaseCorePlugin is registered, its shared initializer calls FirebaseApp.configure() if GoogleService-Info.plist is present.

  3. FIRAppCheckComponent uses FIRInstantiationTimingAlwaysEager, so AppCheck is created inside FirebaseApp.configure(). At that point the provider factory is still the SDK default (FIRDefaultProviderFactory: debug provider with a random token on the simulator, DeviceCheck on a device).

  4. FirebaseAppCheckPlugin.shared calls AppCheck.setAppCheckProviderFactory(FlutterAppCheckProviderFactory()) only when that plugin is registered. That is now after the default app has been configured, so the factory is never used. The later Dart activate() configures FlutterAppCheckProviderFactory, which no instance ever asks for a provider.

Before 3.50 this only worked because "FirebaseAppCheckPlugin" sorts alphabetically before "FLTFirebaseCorePlugin". Dependency ordering is reasonable (app_check depends on core), so it seems the plugin should not rely on registering first. For example, the provider factory could be installed before FirebaseApp.configure() runs, or core could defer configuring the default app.

Reproducing the issue

  1. Create an app with firebase_core and firebase_app_check and a GoogleService-Info.plist in the iOS Runner target. Build with Flutter 3.50.0.
  2. In main():
    await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
    await FirebaseAppCheck.instance.activate(
      providerApple: AppleDebugProvider(debugToken: '<a debug token registered in the console>'),
    );
    final token = await FirebaseAppCheck.instance.getToken();
  3. Run on an iOS simulator.

Expected: the registered debug token is exchanged and getToken() returns a valid token, as it does on Flutter 3.47.9.

Actual: the console prints a newly generated random debug token (not the one passed to activate()), the exchange returns 403, and getToken() fails.

Check: compare ios/Runner/GeneratedPluginRegistrant.m between Flutter 3.47.9 and 3.50.0. The same project, on the same simulator, works on 3.47.9 and fails on 3.50.0.

Firebase Core version

5.1.0 (firebase_app_check 0.5.1, Firebase iOS SDK 13.1.1, Swift Package Manager)

Flutter Version

3.50.0 (works on 3.47.9 and 3.47.5)

Relevant Log Output

App Check debug token: '<random UUID, not the one passed to activate()>'
[FirebaseAppCheck][I-FAA004002] ... exchangeDebugToken ... HTTP status code: 403 ... "App attestation failed."

Flutter dependencies

Expand Flutter dependencies snippet
firebase_core 5.1.0, firebase_app_check 0.5.1, firebase_analytics, firebase_crashlytics, firebase_messaging (latest at the time of writing). iOS uses Swift Package Manager (no Podfile).

Additional context and comments

This is not a duplicate of #18613 or #18665. It is the same mechanism (the default app is configured before FlutterAppCheckProviderFactory is installed, so the eager AppCheck instance keeps the SDK's default provider), but the trigger is different:

#18950 notes that Flutter 3.50 "sorts firebase_core first" in a generated registrant. This issue is a runtime consequence of that ordering on iOS.

Workaround: stay on Flutter 3.47.x.

Activity

  1. SelaseKay commented on Nov 13, 2026

    @SelaseKay
    Contributor

    Hi @DouglasOGarrido, thanks for the detailed report. I'm looking into this.

  2. SelaseKay commented on Nov 13, 2026

    @SelaseKay
    Contributor

    Hi @DouglasOGarrido, thanks for the report.

    This is valid, and your analysis of the cause is correct. The fix is in #18968. firebase_core now lets firebase_app_check install its provider factory before the default app is configured.

    We have a release scheduled for Monday. Until then, you can use the fix from the pull request branch:

    1. Add this to your pubspec.yaml:

      dependency_overrides:
        firebase_core:
          git:
            url: https://github.com/firebase/flutterfire.git
            ref: fix/18966-app-check-provider-factory
            path: packages/firebase_core/firebase_core
        firebase_app_check:
          git:
            url: https://github.com/firebase/flutterfire.git
            ref: fix/18966-app-check-provider-factory
            path: packages/firebase_app_check/firebase_app_check
    2. Run flutter clean, then flutter pub get, and rebuild the app.

    Both overrides are needed, because the change is in both packages. Please let us know if this resolves it for you.

  3. fatihdurmaz commented on Nov 13, 2026

    @fatihdurmaz

    Thanks for the quick response and the fix!

    I applied both dependency overrides and rebuilt the app as suggested. Everything is now working correctly, and Firebase App Check successfully retrieves tokens without any errors.

    I can confirm that the fix resolves the issue on my end.

    Thanks again for your help and great work! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions