For developers · Checked 1 October 2026

Fixing “APNS token has not been set yet” in Firebase Messaging

Short answer: on Apple platforms, the Firebase Messaging SDK since iOS SDK 10.4.0 needs the APNs token from Apple before it can do anything else, and Google warns that the token isn’t guaranteed to have arrived by the time your code calls getToken(). Calling too early throws [firebase_messaging/apns-token-not-set]. Call FirebaseMessaging.instance.getAPNSToken() first and only request the FCM token once it isn’t null. If it never arrives, the setup is incomplete: push capabilities, the APNs key in Firebase, method swizzling, or a device that can’t receive pushes.

Checklist when the APNs token stays null

From Firebase’s FCM setup guides for Flutter and Apple platforms and Apple’s Xcode 14 release notes, read 1 October 2026.

CheckWhat to look for
Order of callsgetAPNSToken() returns a value before getToken() or topic calls
Xcode capabilitiesPush Notifications, plus Background fetch and Remote notifications background modes
APNs key in FirebaseA .p8 authentication key with key ID and team ID in the Cloud Messaging tab
Method swizzlingOn for the Flutter plugin; FirebaseAppDelegateProxyEnabled not set to NO
Test deviceA real device, or Simulator with iOS 16+ on macOS 13+ on an Apple silicon or T2 Mac

Wait for the APNs token

Firebase’s Flutter guide says that from iOS SDK 10.4.0 the APNs token must be available before FCM API requests, and that it isn’t guaranteed to be there in time. Its sample requests permission, then calls getAPNSToken() and only goes on to FCM calls such as getToken() or subscribeToTopic() when the result isn’t null. In practice that means not calling getToken() straight from main() on app start: request permission first, check the APNs token, and if it is still null, try again later rather than letting the exception break startup. Listening to onTokenRefresh catches the FCM token once it becomes available.

When the token never arrives

Capabilities: open ios/Runner.xcworkspace and add Push Notifications, then the Background fetch and Remote notifications background modes. APNs key: in the Firebase console, open Settings > General, then the Cloud Messaging tab, and upload a .p8 APNs authentication key with its key ID and your Apple team ID, for development, production or both. Swizzling: the Flutter plugin needs method swizzling; if FirebaseAppDelegateProxyEnabled is set to NO in Info.plist, token handling won’t work. Native apps that turn swizzling off, and SwiftUI apps, must pass the APNs token to Firebase themselves in application(_:didRegisterForRemoteNotificationsWithDeviceToken:). Device: Simulator only gets remote notifications on iOS 16 or later, running on macOS 13 or later on an Apple silicon or T2 Mac, through the APNs sandbox.

Keep the toolchain current

Once messaging works, keep the iOS side building as Apple raises requirements. FlutterFire wraps the native Firebase SDK, and Firebase has stopped publishing new versions to CocoaPods, see CocoaPods going read-only. Flutter itself moved to iOS 15 as the minimum in Flutter 3.47, and Xcode 27 brings the UIScene requirement, which matters if your AppDelegate handles notifications.

Where Censuus fits

Push notifications bring people back; being found brings them the first time. Censuus ranks apps by the visits they draw, and adding your app is free through the List my app form. Placement comes from traffic and sponsorship: apps climb on the visits they draw, and a sponsor can pay to rise higher.

Frequently asked questions

What does “APNS token has not been set yet” mean?

Firebase Messaging was asked for an FCM token or another API call before iOS delivered the APNs token. Since iOS SDK 10.4.0, the APNs token must be available first.

How do I fix apns-token-not-set in Flutter?

Request permission, call FirebaseMessaging.instance.getAPNSToken(), and only call getToken() when it returns a value. If it stays null, check push capabilities, the APNs key in Firebase and method swizzling.

Why does getAPNSToken() return null?

Usually because Apple hasn’t delivered it yet, or because push isn’t set up: missing Push Notifications capability or background modes, no APNs key uploaded to Firebase, swizzling disabled, or a simulator that can’t receive remote notifications.

Can I get an APNs token on the iOS Simulator?

Yes, on iOS 16 or later running on macOS 13 or later on a Mac with Apple silicon or a T2 chip. The simulator uses the APNs sandbox.

Do I need method swizzling for firebase_messaging?

Yes. Firebase says the Flutter plugin requires method swizzling on Apple devices, and without it FCM token handling won’t work.

Guides for app developers

Put your app in the ranking

Censuus ranks apps by the visits they draw and by sponsorship, no bots. Listing is free; sponsorship raises placement.