30

I'm trying to send a message to my push notification test app. It's been working in proof of concept several weeks ago on the same application but not anymore.

I get a failure: InvalidApnsCredential and Firebase tell us : "A message targeted to an iOS device could not be sent because the required APNs SSL certificate was not uploaded or has expired. Check the validity of your development and production certificates"

But when I check in my firebase console, it tells me that dev and prod certificate will be valid for 9 more months.

What else could be causing this message?

SeikoTheWiz
  • 793
  • 1
  • 9
  • 27

5 Answers5

44

In case if others are also facing the issue here are few tips:

  1. Whenever you are stuck with notification issues try sending a push via the GUI console that firebase provide to send notifications

  2. If your live app at Appstore is not receiving push notification but is receiving notification only when running via Xcode then you have not uploaded the production certificate to the firebase console

  3. If you have uploaded both production and development certificates and still notifications are not received then download the latest certificates and upload them again to the firebase console

harshal jadhav
  • 5,056
  • 2
  • 17
  • 25
  • 53
    What if we're using P8 file, an auth key, and still got this error `InvalidApnsCredential `? – boog Oct 27 '17 at 10:53
  • 1
    Number two fixed my annoying problem! Again man Thanks! I should have noticed the difference between the "development" and "production" certificate – Ahmadiah Mar 02 '18 at 02:18
  • 1
    great ... it made my day... just resolved it using #2.. Thanks alot!! – Er Gagandeep Sethi Jul 11 '18 at 10:52
  • 2
    We have the same issue with our P8 auth key. The whole error message is `{ "error": { "code": 401, "message": "Invalid APNS credential", "status": "UNAUTHENTICATED", "details": [ { "@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError", "errorCode": "APNS_AUTH_ERROR" }, { "@type": "type.googleapis.com/google.firebase.fcm.v1.ApnsError", "statusCode": 403, "reason": "InvalidProviderToken" } ] } }` – blackjacx Jan 17 '19 at 17:44
  • 5
    @boog, make sure your bundle id doesn't have any typos. In my case, I had one camel-cased and the other lowercase. – Jonathan MacDonald Aug 19 '19 at 08:27
  • 1
    I have a working APN p8 uploaded to Firebase, then one day it stopped working. I confirmed all of the above, but it finally started working after I remove my old APNs and created a new one and uploaded it to Firebase. – Joni Oct 01 '20 at 21:41
2

Adding Team id in Firebase worked for me.

Firebase console -> General -> select your app -> Add TEAM ID

You can find team ID in Apple developer portal :

https://developer.apple.com/account/#/membership

Abhijith
  • 2,744
  • 1
  • 27
  • 35
1

In the case of uploading a .p8 file (APNs auth key), adding proper Key ID worked for me.

When you download the .p8 file from Apple. The filename will be in format AuthKey_XXXXXXXXXX.p8. The 10 digit(marked XXXXXXXXXX after the AuthKey_) is the Key ID you need to add.please refer to the image

1

This might pain you to hear, but it seems that the Firebase Cloud Messaging system doesn't like dashes in the bundleID. I had something alongs of my.app.bundle-y and I was receiving InvalidAPNSCredential message on postman... I eventually tried changing my bundle id to my.app.bundle when all else failed, and notifications started coming through.

This is pretty severe change, and only really reasonable if the app is not yet deployed.

If all else fails and you have a dash in your bundle id, then maybe give this a go.

1

I had this issue and was struggling to find a solution even when my APNs token were up to date and etc. I was testing on android before IOS and on the POST method to https://iid.googleapis.com/iid i left "application": com.android name instead of IOS bundle ID. just a stupid error on my side.

Jeronimas
  • 61
  • 6