Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

FCM cannot reach an iPhone: APNs or web push credentials rejected

ErrorTHIRD_PARTY_AUTH_ERROR

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

  • Applies to FCM HTTP v1, Firebase iOS SDK, Firebase console
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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);
    }
  2. 2Match what you see, then jump to its fix

    1. 1Every iOS send fails with THIRD_PARTY_AUTH_ERROR; Android is fineNo APNs authentication key is uploaded to the projectFix
    2. 2Debug builds from Xcode fail, or release and TestFlight builds fail, but not bothThe key for the build you are testing is missing or invalidFix

What does the error look like?

  • THIRD_PARTY_AUTH_ERROR
  • HTTP 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 configuration

2Fix

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

Did this fix it?

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 entry

2Fix

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 key

3Verify

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

Did this fix it?

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:

Related fixes

Mobile 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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.