简体   繁体   中英

InvalidApnsCredential while certificates are valid

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?

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

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

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

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.

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.

in my case I was uploading.p8 key with wrong key id duoble check your "APNs Authentication Key" and make sure u have the right file with the right Key ID and team ID

The Xcode "Bundle Identifier" must match the one configured in Firebase.

In Firebase: Project Settings > Your Apps > Apple Apps

In Xcode: Your project > Targets > General tab > Bundle Identifier

In my case, The Apn.p8 file had been deleted from the Firebase console (and I don't know why: :| )
I had it before and just upload it and the problem was solved. but if you don't have it, you can create a new one from the
Apple developer account -> Certificates -> Keys -> Add new key and check Apple Push Notifications service (APNs) from the services, then download it and upload in
Firebase -> App setting -> Cloud Messaging -> Apple app configuration -> APNs Authentication Key

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM