> For the complete documentation index, see [llms.txt](https://documentation.pushly.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.pushly.com/integration/implementation-steps/apple-ios/p8-key-or-p12-cert-setup.md).

# P8 Key or P12 Cert Setup

## Prerequisites

In order to begin subscribing users to notifications you must have either a P8 Key (recommended) or a P12 Certificate; Either of these can be generated via the Apple Developers portal.

* An [Apple Developer Account](https://developer.apple.com/account/) that has Admin privileges
* Your application's App Bundle ID (e.g., `com.pushly.example`)
* An iOS application or XCode project with the Push Notifications capability added

{% hint style="info" %}
**Which work happens where.** Setting up iOS notifications spans two systems, and the split is easy to conflate:

* **Apple Developer portal** — register the App ID and enable its capabilities, register the devices you will test on, and generate the APNs auth key (`.p8`) or certificate (`.p12`).
* **Pushly dashboard** — upload the `.p8` key along with its `Key ID` and your `Team ID` (or the `.p12` and `Bundle ID`) so that Pushly can send to APNs on your behalf.

The sending credentials are server-side configuration. They are never added to your app's code, `Info.plist`, or entitlements — the app itself only needs its SDK Key.
{% endhint %}

## Register Your App ID

Every app that receives notifications needs an App ID in the Apple Developer portal with the right capabilities enabled. Complete this before generating a key or certificate.

1. [Login](https://developer.apple.com/account/) to your company's Apple Developer account.
2. Click on the `Identifiers` link under `Certificates, Identifiers & Profiles`
3. In the top-right dropdown ensure `App IDs` is selected and click the `+` button next to the `Identifiers` header.
4. Choose `App IDs` from the list of options and press the `Continue` button.
5. Choose `App` as the identifier type and click the `Continue` button.
6. Enter a description. Eg: `YOUR_APP_NAME Push Notifications`
7. Enter the Bundle ID for your app, matching your Xcode project exactly. Eg: `com.pushly.example`
8. Under the `Capabilities` tab check both:
   * `Push Notifications` — required for the app to register with APNs at all.
   * `App Groups` — required for the shared container the PushSDK uses to pass data between your app and its Notification Service Extension. See [<mark style="color:blue;">Configure the Shared App Group</mark>](/integration/implementation-steps/apple-ios/sdk-swift-obj-c.md#step-4-configure-the-shared-app-group).
9. Click the `Continue` and then `Register` button.

{% hint style="warning" %}
Enabling a capability on the App ID is not sufficient on its own — the provisioning profile has to be regenerated afterwards before the entitlement is actually granted to a build. Xcode does this for you when `Automatically manage signing` is enabled. If you manage profiles manually, regenerate and download the profile after changing any capability.
{% endhint %}

## Register a Test Device

Development builds only install on devices that are registered to your team.

* With `Automatically manage signing` enabled, Xcode registers a connected device for you the first time you build to it.
* To register a device manually, go to `Devices` in the Apple Developer portal, click `+`, and enter the device name and its identifier (UDID).

{% hint style="info" %}
Simulators do not need to be registered. A simulator can register with APNs and receive real remote notifications when it meets the requirements in [<mark style="color:blue;">Testing on a simulator</mark>](/integration/implementation-steps/apple-ios/sdk-swift-obj-c.md#testing-on-a-simulator); on setups that do not meet them, token registration has to be exercised on a physical device.
{% endhint %}

## P8 Key Setup (Recommended)

### Step 1: Generate the Key

If you are not renewing an existing P12 certificate we recommend using the newer P8 Key to provide authorization to send notifications. The P8 key will work across all of your applications and environments. You do not need a separate P8 file for developer vs production or for each of your applications.

To create a new P8 key navigate to your [Apple Developer Account](https://developer.apple.com/account/) and click the `Keys` link.

<figure><img src="https://810756845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lry9Z27iWOZyQEGAgY7%2Fuploads%2Fhr66nmrcH5k9oL8e59TU%2Fkeys.png?alt=media&#x26;token=4fff2cf6-6abd-44e0-88d5-18c8ed2976bd" alt=""><figcaption></figcaption></figure>

On the next page click the `+` button next to the `Keys` header

Enter a name for your P8 key; This can be your company name, the name of your application, or any text that will help you identify it later.

Check the `Apple Push Notification service (APNs)` box and click the `Continue` button.

<figure><img src="https://810756845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lry9Z27iWOZyQEGAgY7%2Fuploads%2F1MikHTSIx0icOiCAaWJx%2Fcreate.png?alt=media&#x26;token=d57ce1af-94e1-445b-bc1b-bbb0a32eef50" alt=""><figcaption></figcaption></figure>

On the next page, copy the value provided for `Key ID` and then click the `Download` button to download the P8 Key.

<figure><img src="https://810756845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lry9Z27iWOZyQEGAgY7%2Fuploads%2FlZQkYbTrhXRRZERcCaec%2FScreenshot%202022-12-12%20at%204.10.09%20PM.png?alt=media&#x26;token=3ba39f9c-e7b6-473d-808a-b289075eb454" alt=""><figcaption></figcaption></figure>

The last piece of information we need is the `Team ID` associated to your membership and can be found in the top right of the screen underneath your name.

<figure><img src="https://810756845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lry9Z27iWOZyQEGAgY7%2Fuploads%2FXFo3595GgoygzfAbErcN%2FScreenshot%202022-12-12%20at%204.19.50%20PM.png?alt=media&#x26;token=24947664-83c3-4817-976e-33cbe23f9963" alt=""><figcaption></figcaption></figure>

### Step 2: Enable Integration in Pushly

Now that you have the `Team ID`, `Key ID` , and the P8 Key you can log into the Pushly platform, navigate to the `Settings` page, and locate the `Send Integrations` section.

For here, click the `Edit` button in the `Send Integration` header, enable the `Native` switch under the `Apple` heading and:

1. Choose `P8 Cert` from the pill selection
2. Click the certificate area to upload your P8 Key
3. Enter the `Team ID`
4. Enter the `Key ID`
5. Click the `Submit` button

<figure><img src="https://810756845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lry9Z27iWOZyQEGAgY7%2Fuploads%2FzISEeeHVthIJ2AVhffo5%2FScreenshot%202023-02-01%20at%209.29.20%20AM.png?alt=media&#x26;token=2a1e22e1-3c51-435c-8f39-8e20a9a8a65e" alt=""><figcaption></figcaption></figure>

If everything was entered correctly you should now see a section underneath `Send Integrations` that shows an active Apple Native integration.

<figure><img src="https://810756845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lry9Z27iWOZyQEGAgY7%2Fuploads%2Fnwbudz0lLpKSXyWiK5Eo%2FScreenshot%202023-02-01%20at%209.27.22%20AM.png?alt=media&#x26;token=b86668f2-c739-4630-a063-629a7c78bc7f" alt=""><figcaption></figcaption></figure>

## P12 Certificate Setup

We do not recommend creating new P12 Certificates in favor of using P8 Keys. If you have an existing P12 Certificate follow the steps below to renew it and add it to the platform.

### Step 1: Create a Certificate Request (CSR)

1. On a Mac computer Open the `Keychain Access` application
2. Within the `Keychain Access` primary application menu, select `Keychain Access` > `Certificate Assistant` > `Request a Certificate from a Certificate Authority`
3. In the Certificate Information window, enter the following information:
   * In the `User Email Address` field, enter your email address.
   * In the `Common Name` field, create a name for your private key (e.g. Company Name Web Push).
   * The `CA Email Address` field should be left empty.
   * In the `Request` group, select the `Saved to disk` option.
4. Click `Continue` within Keychain Access and save the CSR to disk to complete this step.

### Step 2: Create an Identifier for Your App

{% hint style="danger" %}
If you already completed [<mark style="color:blue;">Register Your App ID</mark>](#register-your-app-id) above, or you are renewing an existing certificate, skip this step and move to Step 3 — the App Identifier already exists within your Apple developer account.
{% endhint %}

1. [Login](https://developer.apple.com/account/ios/certificate/) to your company's Apple Developer Console account.
2. Click on the `Identifiers` link under `Certificates, Identifiers & Profiles`
3. In the top-right dropdown ensure `App IDs` is selected and click the `+` button next to the `Identifiers` header.
4. Choose `App IDs` from the list of options and press the `Continue` button.
5. Choose `App` as the identifier type and click the `Continue` button
6. Enter a description. Eg: `YOUR_APP_NAME Push Notifications`
7. Enter the Bundle ID for your app. Eg: `com.YOUR_APP_NAME.app-push`
8. Under the `Capabilities` tab scroll down and check the `Push Notifications` capability
9. Click the `Continue` and then `Register` button.

### Step 3: Generate a Web Push Certificate

1. Click on `Certificates` in the left nav and press the `+` sign next to the `Certificates` header
2. Choose `Apple Push Notification service SSL (Sandbox & Production)` from the list of Services and then click `Continue`.
3. Select the App Identifier that corresponds to the application for which you are generating the certificate and click the `Continue` button.
4. Click the `Choose File` button, browse for the CSR file that we created in the first step, and click `Continue`.
5. The next screen informs you that your certificate is ready. Click `Download` to store the certificate on your computer.

### Step 4: Generate the .p12 Certificate

* Navigate to the certificate you saved on your computer and double click it to install it to the `Keychain Access` application.
* Open the `Keychain Access` application and click on `My Certificates` tab with the `Login` keychain selected in the left navigation section.
* Right click on the installed Apple Push Services certificate and choose `Export`.
* In the save dialog, choose a filename (or leave the default), choose the `.p12` file format, and click the `Save` button.
* You will be prompted to enter a password - leave both boxes empty and click `OK`.
* Click `Allow` to save the p12 certificate to your computer.

### Step 5: Upload the Certificate via the Platform

Now that you have the `Bundle ID` and the P12 Certificate you can log into the Pushly platform, navigate to the `Settings` page, and locate the `Send Integrations` section.

For here, click the `Edit` button in the `Send Integration` header, enable the `Native` switch under the `Apple` heading and:

1. Enter the application's `Bundle ID`
2. Choose `P12 Cert` from the pill selection
3. Click the area to upload your P12 Certificate
4. If you entered a passphrase when generating the certificate enable the switch and add it
5. Click the `Submit` button


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://documentation.pushly.com/integration/implementation-steps/apple-ios/p8-key-or-p12-cert-setup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
