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).

Metadata

Metadata

Assignees

No one assigned

    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