p8 Token-Based Connection to APNs

Step 1. Requirements

  • An iOS mobile app. (This is not for websites / web push)
  • An Apple Developer Account with Admin Role.
  • A Mac computer with Xcode 11+
  • Your Xcode project should have the Push Notification capability added. Otherwise your project may not be shown in the Apple Developer Center.

Step 2. Generate a new p8 key

  • Log in to your Apple Developer Account and navigate to Certificates, Identifiers & Profiles > Keys and select the Blue + button.
  • Select Apple Push Notifications service (APNs), and enter a name for the key
  • Select Continue and on the next page, select Register.
  • Download your new key and save it in a secure place. You can only download it once, so don't lose it. Then, click Done and you will have a new key.

Note: .p8 keys are in the “keys” section of the Apple developer account and the .p12 certificates are under “certificates”. In your Apple account, you can only have two .p8 keys, but you can have both active .p12s and .p8s.

Step 3. Provisioning Profiles

  • Skip if selected "Automatically manage signing" in Xcode.
  • If you did not select "Automatically manage signing", then follow these steps.

Create Your Profile

  • Go to your Apple Developer Account > Certificates, Identifiers & Profiles > Profiles.
  • Next find any that are for your app and remove them if they do not have App Groups and Push Notifications in Enabled Capabilities:
  • Create a Profile by pressing the "+" button
  • Select the type of profile you need to create and press Continue.
  • Select the Development or Distribution Certificate to associate with the Profile. Then click Continue.
  • Name your Provisioning Profile.
  • Select Generate.
  • On the last page Download your profile.
  • Re-sync your Developer Account in Xcode by going to Xcode > Preferences... then click on the "View Details..." button. Then, click the refresh button on the bottom left of the popup. See Apple's documentation for more detailed instructions.
  • Make sure you pick your new provisioning profile from Build Settings>Code Signing>Provisioning Profile in Xcode.

Copyright © 2024