Ad

IOS - What Happens I Lost My APNs Key File?

I just created the APNs Key file from Apple Developer website. It was saying "Don't lost this key". I already have a backup but what happens if I lost it?

It is also saying I just need one APNs Key for all apps.

Can I create more than one APNs Key or should I go with just one? If I lost this am I going to can't send notifications for just that app or none of my apps?

Thanks in advance.

Ad

Answer

You can have MULTIPLE .p8 files. The .p8 file is used to generate a JWT Token on the server side and that is used to send push notifications via HTTP2 to Apple's APNS server. Only problem is that if you lose it, you have to regenerate a new one on the server side. It doesn't affect existing apps at all because it's bound to the bundleId, applicationId, and developer account.

In other words, it's not a certificate that the app has to be re-signed with or anything.

Scenario to make it simpler:

  • I create an app called MyApp with BundleId: com.SO.myApp.
  • I create an APNS .p8 file with account RT8NCD.
  • On the server side, I use this .p8 file to send notifications to com.SO.myApp via HTTP2 and JWT Token generation.
  • I release the app to the AppStore.

  • I then LOST the .p8 file and can't send push to my app which is already on the store!

What do I do?

  • I go into the developer portal and re-create a NEW .p8 file with the same AppId and BundleId and same account.
  • Then on the server side I use this .p8 file to send push notifications to the devices registered in my database.
  • I do not need to release a new app or new version or anything.

So in other words, there's not really any consequences to losing it.. but it's not a good idea to get into the practice of losing keys, certificates, etc.. Seriously.

P.S. I cannot guarantee that this behaviour won't change in the future. It's Apple. Try not to lose things.

Ad
source: stackoverflow.com
Ad