FirebaseMessaging.getAPNSToken() returns null on iOS
FirebaseMessaging.instance.getAPNSToken() returns nullShort answer
getAPNSToken() gives null when iOS has not handed the app an APNs token yet or never will. The usual reasons: no APNs key in Firebase, push and remote-notification capabilities missing in Xcode, method swizzling off, or the call made too early. Check each, and ask for the token again after permission is granted.
Fix it fast
1Find out which cause you have
Ask for notification permission first, then request the token, and print both. If permission is denied, none of the causes below matter.
final settings = await FirebaseMessaging.instance.requestPermission(); debugPrint('permission: ${settings.authorizationStatus}'); final apns = await FirebaseMessaging.instance.getAPNSToken(); debugPrint('apns: $apns');2Match what you see, then jump to its fix
- 1
null on the first call, but a later call returns a valueThe token is requested before iOS has delivered itFix - 2
Permission is granted but the token stays null on every launchPush Notifications and background modes are not enabled in XcodeFix - 3
The APNs token exists on the device, but pushes sent from Firebase never arriveNo APNs authentication key has been uploaded to FirebaseFix - 4
FirebaseAppDelegateProxyEnabled is NO in Info.plistMethod swizzling is switched offFix
- 1
What does the error look like?
FirebaseMessaging.instance.getAPNSToken() returns null
Cause 1 of 4
The token is requested before iOS has delivered it
1Check
Firebase documents that the APNs token is not guaranteed to exist when the FCM plugin is called, and that from iOS SDK 10.4.0 it must exist before any FCM API request. Log the value a few seconds after launch to see if it appears.
await Future.delayed(const Duration(seconds: 3));
debugPrint('apns: ${await FirebaseMessaging.instance.getAPNSToken()}');2Fix
Request permission, then read the APNs token, and call other FCM methods (such as getToken) only when it is not null. If it is null, retry after a short delay.
await FirebaseMessaging.instance.requestPermission();
String? apns;
for (var i = 0; i < 5 && apns == null; i++) {
apns = await FirebaseMessaging.instance.getAPNSToken();
if (apns == null) await Future.delayed(const Duration(seconds: 1));
}
if (apns != null) {
final fcm = await FirebaseMessaging.instance.getToken();
}3Verify
The log prints a long hex string for apns, and getToken returns an FCM token.
flutter run --releaseConfirmed by firebase.google.com
Cause 2 of 4
Push Notifications and background modes are not enabled in Xcode
1Check
Open ios/Runner.xcworkspace, select the Runner target, Signing and Capabilities. Firebase says push notifications and the Background fetch and Remote notifications background modes must be enabled.
open ios/Runner.xcworkspace2Fix
Add the Push Notifications capability, and under Background Modes tick Background fetch and Remote notifications.
# Xcode: Runner target > Signing & Capabilities
# + Capability > Push Notifications
# + Capability > Background Modes > Background fetch, Remote notifications3Verify
Rebuild and run on a device. The token is no longer null.
flutter clean && flutter runConfirmed by firebase.google.com
Cause 3 of 4
No APNs authentication key has been uploaded to Firebase
1Check
In the Firebase console open Project settings, Cloud Messaging tab, and look under APNs authentication key. Firebase requires at least one key, development or production.
# Firebase console > Project settings > Cloud Messaging > Apple app configuration2Fix
Create a key in the Apple Developer account and upload the .p8 file with its key ID and your team ID.
# Upload: the .p8 file, the Key ID, and the Apple Team ID3Verify
Send a test message from the Firebase console to the device token.
# Firebase console > Messaging > New campaign > Send test messageConfirmed by firebase.google.com
Cause 4 of 4
Method swizzling is switched off
1Check
The FCM Flutter plugin needs method swizzling on Apple platforms. If the flag is NO, the plugin never sees the APNs token iOS hands to the app delegate.
grep -A1 FirebaseAppDelegateProxyEnabled ios/Runner/Info.plist2Fix
Remove the key (the default is enabled) or set it to true.
<key>FirebaseAppDelegateProxyEnabled</key>
<true/>3Verify
Rebuild the app; getAPNSToken returns a value on a device.
flutter runConfirmed by firebase.google.com
How do I stop it coming back?
- Wrap token logic in one function that requests permission first, then waits for the APNs token.
- Keep the push and background-mode capabilities in the committed Xcode project.
- Upload both a development and a production APNs key.
- Leave method swizzling on unless you map the APNs token by hand.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
Related fixes
Mobile apps
Xcode cannot find GoogleService-Info.plist for the Runner target
error: Build input file cannot be found: '/Users/GoogleService-Info.plist' (in target 'Runner' from project 'Runner')
Xcode's project file lists GoogleService-Info.plist as an input, but nothing exists at the path it records.
3 causes, each with a fixMobile apps
Firebase phone sign-in on iOS stops with 'Please register custom URL scheme'
Please register custom URL scheme com.googleusercontent.apps.123456789-abc in the app's Info.plist file.
Phone sign-in on iOS can open a reCAPTCHA page, and Firebase needs a URL scheme in Info.plist to return to your app.
2 causes, each with a fixMobile apps
CocoaPods refuses a Swift pod that depends on a pod without modules
... does not define modules.
CocoaPods builds Swift pods as static libraries only if every pod they import defines a module.
2 causes, each with a fixMobile apps
Swift cannot import a module that is installed in the project
No such module 'Flutter'
The compiler for this target cannot see the module, even though the code exists on disk.
4 causes, each with a fixMobile apps
Gradle cannot find com.google.firebase:firebase-analytics-ktx
Required by: project :app
Firebase moved the Kotlin extensions into the main modules and stopped releasing the -ktx modules in July 2025.
2 causes, each with a fixMobile apps
Apple rejected the app under Guideline 4.3, Design: Spam
Guideline 4.3(b) - Design - Spam
Guideline 4.3 is Apple's duplicate rule.
5 causes, each with a fix