FCM cannot reach an iPhone: APNs or web push credentials rejected
THIRD_PARTY_AUTH_ERRORShort answer
THIRD_PARTY_AUTH_ERROR is HTTP 401. FCM could not send to an iOS device or web push registration because the APNs certificate or web push key in your Firebase project is invalid or missing. Open the Cloud Messaging settings, confirm an APNs key is uploaded, and check that both development and production credentials are present.
Fix it fast
1Find out which cause you have
Find out which platform fails. Android tokens succeeding while iOS tokens fail means the APNs setup is the problem, not your server credentials.
try { await getMessaging().send({ token: iosToken, notification: { title: 'Hi', body: 'Test' } }); } catch (e) { console.error(e.code, e.message); }2Match what you see, then jump to its fix
What does the error look like?
THIRD_PARTY_AUTH_ERRORHTTP 401 when sending to an iOS registration token
Cause 1 of 2
No APNs authentication key is uploaded to the project
1Check
In the Firebase console open Settings, then the Cloud Messaging tab, and look under APNs authentication key in the iOS app configuration.
# Firebase console > Settings > Cloud Messaging > iOS app configuration2Fix
Create a key in the Apple Developer Member Center, then upload it under APNs authentication key with its key ID. The setup guide says at least one key (development or production) is required.
# Firebase console > Cloud Messaging > APNs authentication key > Upload (key file + key ID)3Verify
Send the same test message to the iOS token again.
console.log(await getMessaging().send({ token: iosToken, notification: { title: 'Hi', body: 'Test' } }));Confirmed by firebase.google.com
Cause 2 of 2
The key for the build you are testing is missing or invalid
1Check
The console accepts a development key, a production key, or both. The error reference tells you to verify your development and production credentials, so check that the one matching your build type is present and still valid.
# Firebase console > Cloud Messaging: look for both a development and a production entry2Fix
Upload the missing key, or replace one that was revoked in the Apple Developer account. Uploading both a development and a production key removes the guesswork.
# Firebase console > Cloud Messaging > Upload development key and production key3Verify
Send one message to a token from a debug build and one to a token from a release build.
console.log(await getMessaging().send({ token: debugToken, notification: { title: 'Debug', body: 'ok' } }));Confirmed by firebase.google.com
How do I stop it coming back?
- Upload both development and production APNs keys when you set up the project.
- Write down which Apple account issued the key, so a revoked key is easy to trace.
- Test one iOS device and one Android device after every credential change.
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
Firebase on iOS asks for the FCM token before APNs has given one
Be sure to re-retrieve the FCM token once the APNS device token is set.
The Firebase Messaging SDK needs the APNs device token from iOS before it hands out an FCM token.
3 causes, each with a fixMobile apps
The iOS push arrives from FCM but plays no sound
A custom sound name in the payload is ignored and nothing plays
iOS plays a sound for a remote notification only when the aps payload has a sound key and the app is allowed to play sounds.
3 causes, each with a fixMobile apps
FirebaseInstanceIdService and FirebaseInstanceId.getToken() no longer work
Deprecation warning on FirebaseInstanceId.getInstance().getToken()
Move token handling into a class that extends FirebaseMessagingService and override onNewToken, which runs when a token is first created and whenever it changes.
2 causes, each with a fixMobile apps
FCM rejects the message with INVALID_ARGUMENT
HTTP 400 from fcm.googleapis.com/v1/projects/PROJECT_ID/messages:send
INVALID_ARGUMENT is HTTP 400: FCM did not accept the request parameters.
3 causes, each with a fixMobile apps
Push sending broke because the server still uses the legacy FCM API
Console notice that the legacy Firebase Cloud Messaging API is deprecated
Sends that still use the legacy FCM API (a server key in the Authorization header) or old Admin SDK methods need to move to the HTTP v1 API.
3 causes, each with a fixMobile apps
Logcat warns that FCM has no default notification channel in AndroidManifest
Notification does not appear on Android 8 and later
This is a warning, not a crash.
3 causes, each with a fix