Skip to content

Flutter iOS push errorFlutter push on iOS: “APNS token has not been set yet”

Your Flutter app gets an FCM token on Android, but on iPhone firebase_messaging throws apns-token-not-set, or push never arrives. Here’s what Firebase’s docs say to check, in their own words, or hand it over at a fixed price.

Short answer

On Apple platforms the APNs token has to be available before you make FCM plugin calls, and it isn’t guaranteed to have arrived yet. Request notification permission, check that getAPNSToken() returns a value, then make your other FCM calls. If it never arrives, check that Push Notifications and the background modes are on in Xcode, that an APNs authentication key is uploaded in the Firebase console, and that method swizzling hasn’t been turned off.

What to check, in order

  1. 01

    FCM is called before the APNs token arrives

    “In iOS SDK 10.4.0 and higher, it is required that the APNs token is available before making API requests.” Firebase, FCM in Flutter apps

    Firebase warns that the APNs token isn’t guaranteed to have been received before you make FCM plugin API requests. Request permission first, then check that getAPNSToken() returns a value before any other FCM call, as in Firebase’s example.

    // You may set the permission requests to "provisional" which allows the user to choose what type
    // of notifications they would like to receive once the user receives a notification.
    final notificationSettings = await FirebaseMessaging.instance.requestPermission(provisional: true);
    // For apple platforms, make sure the APNS token is available before making any FCM plugin API calls
    final apnsToken = await FirebaseMessaging.instance.getAPNSToken();
    if (apnsToken != null) {
      // APNS token is available, make FCM plugin API requests...
    }
  2. 02

    Push isn’t enabled in Xcode

    “Before your application can start to receive messages, you must enable push notifications and background modes in your Xcode project.” Firebase, FCM in Flutter apps

    Open ios/Runner.xcworkspace, add the Push Notifications capability, and turn on the Background fetch and Remote notifications background modes.

  3. 03

    No APNs authentication key in Firebase

    “Before you use FCM, upload your APNs authentication key to Firebase.” Firebase, FCM in Flutter apps

    In the Firebase console, open Settings, then General, then the Cloud Messaging tab. Under iOS app configuration, upload a development or production APNs authentication key (at least one is required): the .p8 file, its key ID and your Apple team ID. Create the key in the Apple Developer Member Center if you don’t have one.

  4. 04

    Method swizzling is turned off

    “To use the FCM Flutter plugin on Apple devices, method swizzling is required.” Firebase, FCM in Flutter apps

    If Info.plist sets FirebaseAppDelegateProxyEnabled to NO, swizzling is disabled, and the FCM Flutter plugin requires it. Remove the flag.

Checked against the vendor’s docs on : Firebase docs: Get started with FCM in Flutter apps; Firebase docs: FCM in Apple platform apps (method swizzling).

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

Related: Flutter pod install failed · Expo push notifications not working · FCM legacy API shutdown

Questions

More on this error

Why does it work on Android but not on iPhone?

On Apple platforms, Firebase says the app needs the APNs token before FCM plugin calls, push enabled in Xcode, and an APNs authentication key uploaded to Firebase.

Do I need a development and a production APNs key?

Firebase asks for at least one. You can upload a development key, a production key, or both, each with its key ID and your Apple team ID.

What do I need to give you to fix this?

The Flutter project and access to the Firebase project. We check the token order in your code, the Xcode settings and the APNs key, and send the fix as a pull request you review and build.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; we reply by email, usually within one business day.