Skip to content

[firebase_messaging]: 16.5.0 never receives APNs token under UIScene (apns-token-not-set) — regression from 16.4.3 #18555

Description

@kylehuang17

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Messaging

Which platforms are affected?

iOS

Description

After upgrading firebase_messaging from 16.4.3 to 16.5.0, physical iOS devices running a UIScene-based Flutter app never receive the APNs device token, so FCM tokens can never be obtained and push notifications are completely broken.

  • FirebaseMessaging.instance.getAPNSToken() returns null indefinitely (polled every 500ms for 3s, still null 11+ seconds after launch).
  • FirebaseMessaging.instance.getToken() throws [firebase_messaging/apns-token-not-set] APNS token has not been received on the device yet.
  • onTokenRefresh never fires.
  • Notification permission is already authorized; aps-environment entitlement is present (development for debug, production for release); pushes to previously-obtained tokens still arrive, so certificates/entitlements are fine.

This is a regression from 16.4.3: the identical app (same UIScene setup, same AppDelegate, same entitlements) ran in production alongside UIScene for five months on 16.4.3 with working push. The only change was the plugin upgrade to 16.5.0. Pinning back to 16.4.3 immediately restores APNs token delivery on the same device.

We did apply the new 16.5.0 UIScene guidance: FLTFirebaseMessagingPlugin.configureNotificationCenterDelegate() is called in application(_:didFinishLaunchingWithOptions:) before returning super.... That fixes the notification-center delegate setup, but the APNs device token registration path (didRegisterForRemoteNotificationsWithDeviceToken → FIRMessaging) still appears to be broken under scene-based lifecycle — the token never reaches the SDK.

App setup:

  • Info.plist contains UIApplicationSceneManifest with UISceneDelegateClassName = FlutterSceneDelegate (adopted 5 months ago, worked with 16.4.3).
  • AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate (plugins registered in didInitializeImplicitFlutterEngine).
  • Method swizzling enabled (no FirebaseAppDelegateProxyEnabled key; no manual didRegisterForRemoteNotifications forwarding).
  • setAutoInitEnabled(true) is called explicitly at startup.

Reproducing the issue

  1. Flutter app with UIScene adoption (UIApplicationSceneManifest + FlutterSceneDelegate) and FlutterAppDelegate + FlutterImplicitEngineDelegate.
  2. firebase_messaging: 16.5.0, call FLTFirebaseMessagingPlugin.configureNotificationCenterDelegate() in didFinishLaunchingWithOptions per the 16.5.0 README.
  3. Run on a physical iPhone with notification permission granted.
  4. Call getAPNSToken() (null forever) then getToken() → throws apns-token-not-set.
  5. Downgrade only firebase_messaging to 16.4.3 (and remove the 16.5-only delegate call) → APNs token arrives, getToken() succeeds.

Firebase Core version

4.x (Podfile.lock: Firebase iOS SDK 12.17.0)

Flutter Version

3.41.9 (stable)

Relevant Log Output

[firebase_messaging/apns-token-not-set] APNS token has not been received on the device yet. Please ensure the APNS token is available by calling `getAPNSToken()`.

Additional context and comments

Workaround for anyone hitting this: pin firebase_messaging: 16.4.3 and remove/comment the configureNotificationCenterDelegate() call (16.5-only API).

Activity

  1. SelaseKay commented on Aug 10, 2026

    @SelaseKay
    Contributor

    Hi @kylehuang17, thanks for the report. We'll investigate this further.

  2. SelaseKay commented on Aug 10, 2026

    @SelaseKay
    Contributor

    Hi @kylehuang17, I followed your steps to reproduce the issue on my end using the firebase_messaging example app, but I wasn't able to reproduce it.

    Have you tried running the app on a different iOS device? If so, was the issue still reproducible? Also, have you tried reproducing it with Flutter 3.44.0?

    If the issue persists, could you please share a minimal reproducible example that I can run locally? That would help me investigate this further. Thanks!

  3. added
    blocked: customer-responseWaiting for customer response, e.g. more information was requested.
    and removed
    Needs AttentionThis issue needs maintainer attention.
    on Aug 10, 2026
  4. elau8465 commented on Aug 12, 2026

    @elau8465

    Confirming this on a second app and a different physical device, and notably without the configureNotificationCenterDelegate() call — so the regression doesn't depend on having adopted the 16.5.0 UIScene guidance.

    Environment

    • firebase_messaging 16.4.0 → 16.5.0, as part of a wider FlutterFire bump
    • firebase_core 4.13.0, Firebase iOS SDK 12.17.0 (CocoaPods; SPM disabled)
    • Flutter 3.44.9 stable, Dart 3.12.2
    • Physical iPhone 16 Pro (iPhone17,1), iOS 26.6
    • UIApplicationSceneManifest with a SceneDelegate: FlutterSceneDelegate subclass
    • AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate, plugins registered in didInitializeImplicitFlutterEngine
    • Swizzling enabled (no FirebaseAppDelegateProxyEnabled key)
    • aps-environment: development, notification permission already granted

    Symptom

    Our registration path only polls once getNotificationSettings() reports authorized, so permission is confirmed granted at the time of the call. Polling getAPNSToken() 40 × 300ms:

    Runner  flutter: APNs token unavailable after 12125ms
    Runner  flutter: APNs token unavailable after 12114ms
    

    Null for the full 12s, on both calls within a single launch. onTokenRefresh never fires and no FCM token is ever obtained. The same device registered normally on the previous build.

    Re: Flutter 3.44 — reproduces on 3.44.9 stable, so this isn't specific to 3.41.x.

    Difference from the original report: we never called FLTFirebaseMessagingPlugin.configureNotificationCenterDelegate(). The original report applied that guidance and still lost the token; we never applied it and also lost the token. So the APNs device-token path appears broken under scene lifecycle independently of notification-center delegate setup.

    Pinning firebase_messaging: 16.4.3 while leaving firebase_core 4.13.0 / Firebase iOS SDK 12.17.0 and every other FlutterFire plugin at their latest resolves cleanly in CocoaPods and restores APNs token delivery on the same device — which also isolates this to the messaging plugin rather than the 12.17.0 SDK bump.

    No standalone minimal repro yet; happy to put one together if the config above isn't enough to go on.

  5. arlakay commented on Aug 17, 2026

    @arlakay

    I'm experiencing the same issue on an iPhone XR.

    The issue was recorded in Crashlytics with the following error:

    [firebase_messaging/apns-token-not-set] APNS token has not been received on the device yet. Please ensure the APNS token is available before calling getAPNSToken().

    We're currently using:

    • firebase_core: ">=4.10.0 <4.12.0"
    • firebase_messaging: ">=16.3.0 <16.4.2"
    • Flutter SDK 3.41.6

    Update #1: I haven't performed the migration related to the UISceneDelegate changes yet.
    Reference: https://docs.flutter.dev/release/breaking-changes/uiscenedelegate

  6. self-assigned this
    on Aug 17, 2026
  7. SelaseKay commented on Aug 18, 2026

    @SelaseKay
    Contributor

    Hi all, I'm still unable to reproduce this on my end. Tested with both UIScene and non-UIScene enabled apps. getAPNSToken() successfully resolved in both cases. Kindly share a minimal repo I can clone and run to investigate this further.

  8. arlakay commented on Aug 18, 2026

    @arlakay

    Please try the following:

    Future<void> main() async {
      WidgetsFlutterBinding.ensureInitialized();
      await Firebase.initializeApp();
    
      // Comment this section to force reproduce the APNs error above.
      // if (Platform.isIOS) {
      //   final settings = await FirebaseMessaging.instance.requestPermission();
      //   print('Settings registered = ${settings.authorizationStatus}');
      // }
    
      final fcmToken = await FirebaseMessaging.instance.getToken();
      print('FCM Token = $fcmToken');
    
      runApp(const MyApp());
    }

    However, in the actual use case, even when requestPermission() returns authorized, the APNs error above can still occur.

  9. Lyokone commented on Aug 18, 2026

    @Lyokone
    Contributor

    @arlakay A full reproduction sample is a GitHub repo we can clone and test out without any modification, reproducing the issue. A code sample is not enough. Please share a full reproduction sample.

  10. arlakay commented on Aug 19, 2026

    @arlakay

    see this PR : https://github.com/firebase/flutterfire/pull/11400/changes
    it's mentioned on client.md
    // For apple platforms, ensure the APNS token is available before making any FCM plugin API calls

    update 26 August,

    • hope this help, check your mobile provision certificate, cause on my cases the provisioning status "invalid"
  11. wantroba commented on Aug 24, 2026

    @wantroba

    Same problem here

  12. tonileppanen commented on Aug 24, 2026

    @tonileppanen

    configureNotificationCenterDelegate() only sets UNUserNotificationCenter.delegate; it never calls registerForRemoteNotifications(), which still runs from launch/scene callbacks that have already fired. That is why getAPNSToken() stays null.

    The example app can miss this: getToken() is invoked from a widget initState, after the first frame, and a prior run often leaves a cached APNs token, so a warm launch succeeds.

  13. wantroba commented on Aug 24, 2026

    @wantroba

    For testing purposes, I modified my code so that while getAPNSToken is null, I wait a second and make the request again until the value arrives. It never arrives.

  14. Wim-Hexagons commented on Aug 25, 2026

    @Wim-Hexagons
    Image I can confirm the same issue. My 1.14.6 version contains the update to 16.5.0 and I noticed a lot of users running into this.
  15. wantroba commented on Aug 25, 2026

    @wantroba

    I don't know if it helps, but I inserted this code into my app, and I'm going to paste some results here.

    static Future<void> fetchAPNSToken() async {
        if (Platform.isIOS) {
          String? token;
          int retries = 0;
    
          while (token == null && retries < 1000) {
            token = await FirebaseMessaging.instance.getAPNSToken();
            if (token == null) {
              await Future.delayed(Duration(seconds: 2));
              retries++;
            }
          }
          if (retries > 0) {
            FirebaseUtils.recordError(
              Exception("Final APNS Token: $token after $retries retries"),
              StackTrace.current,
            );
          }
        }
      }
    

    Logs received by Firebase Crashlytics:

    Final APNS Token: XXXXXX after 7 retries
    Final APNS Token: XXXXXX after 5 retries
    Final APNS Token: XXXXXX after 1 retries
    Final APNS Token: XXXXXX after 199 retries
    Final APNS Token: XXXXXX after 200 retries
    Final APNS Token: null after 1000 retries

  16. Wim-Hexagons commented on Aug 26, 2026

    @Wim-Hexagons

    Can confirm that rolling back to 16.4.3 fixes it. This was a major production issue, new iOS users (and users for which the token expired) were unable to generate the token and thus excluded from the push notification system I have in place.

  17. SelaseKay commented on Aug 26, 2026

    @SelaseKay
    Contributor

    Hi all — thanks for the reports.

    Credit to @tonileppanen for pinning this down: configureNotificationCenterDelegate() only sets UNUserNotificationCenter.delegate. It never asks iOS for an APNs token. Registration still ran from didFinishLaunching / scene:willConnect, and under UIScene those callbacks can fire before the plugin exists, so registerForRemoteNotifications() was never called and getAPNSToken() stayed null.

    I’ve opened a PR to fix this: #18620:

  18. huytofu commented on Sep 1, 2026

    @huytofu

    Hi all, I notice this warning from building in IOS. Not sure if this could play a part in contributing to the above issue

    Conflicting return type in implementation of 'scene:willConnectToSession:options:': 'BOOL' (aka 'bool') vs 'void'
    Happening together with firebase_messaging == 16.6.0

    diagnosis by AI:

    This error occurs because you have implemented the scene:willConnectToSession:options: delegate method with a BOOL return type, but the official Apple Developer Documentation

  19. locked and limited conversation to collaborators on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

blocked: customer-responseWaiting for customer response, e.g. more information was requested.platform: iosIssues / PRs which are specifically for iOS.plugin: messagingtype: bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions