> ## Documentation Index
> Fetch the complete documentation index at: https://kb.aampe.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Apple Push Notification service (APNs)

> Estimated setup time: 1 hour

## Requirements

* An encryption key (.p8 file) and its key ID
* Your team ID and bundle ID/APNs topic
* APNs user device tokens

## Setup

Aampe will essentially establish a [token-based connection to APNs](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_token-based_connection_to_apns) and use that to trigger notifications on your behalf.

## Generating Key

1. Login to your Apple developer account.
2. In [Certificates, Identifiers & Profiles](https://developer.apple.com/account/resources), click **Keys** in the sidebar, then click the add button (+) on the top left.
3. Under **Key Name**, enter a unique name for the key.
4. Select the checkbox next to the services you want to enable, then click **Continue**.
   * If the Media Services checkbox is disabled, you need to register a media identifier first.
   * If you register more than one media identifier, click **Configure** next to the checkbox.
   * On the next page, choose the media identifier you want to use from the pop-up menu, then click **Continue**.
5. Review the key configuration, then click **Confirm**.
6. Click **Download** to generate and download the key. This is the key you will share with Aampe.
7. Click **Done**.

## APNs User Device Tokens

For Aampe to be able to trigger push notifications for your users, it needs to have a device token for each user. You can share those directly using a daily dump to an S3/GCP bucket.

If you are already sharing user properties data with Aampe, the APNs device token for each user can simply be added as a column to the shared attribute table. See [Properties](https://aampe-docs.readme.io/docs/data-models#user-properties).

If you are not sharing attribute data with Aampe then the easiest way to share APNs device tokens is by setting up a daily job that dumps a file with the tokens to a storage bucket. Aampe will take care of ingesting those tokens and always taking the latest value for each user in case of token updates.

### Data Format

| Name                | Data Type | Description              |
| :------------------ | :-------- | :----------------------- |
| contact\_id         | String    | A unique user identifier |
| notification\_token | String    | APNs device token        |

***
