Skip to main content

Apple Push Notification

Generating .p8 key file

To generate a .p8 key file, go to the Apple developer account page, then select Certificates, IDs & Profiles.

Next, select Keys.

Click the “+” button to add a new key.

On the new key page, type in your key name and check the Apple Push Notification service (APNs) box, then click “Continue” and click “Register".

Then proceed to download the key file by clicking Download.

The Auth Key filename will look like this: AuthKeyABCD1234.p8, the ABCD1234 is the Key ID for this key, we will need this Key ID to configure APN in Courier.

As for the Team ID, you can get this on your Apple developer account membership page:

Install APN in Courier

Profile Requirements

Courier support sending Apple Push Notifications using single and multiple tokens. To deliver a message to a recipient over Apple Push Notifications, Courier must be provided the recipient's APN registration token. These tokens should be included in the recipient profile as apn.token for single tokens and apn.tokens for multiple.

Single Token

JSON
{
"profile": {
"apn": {
"token": "YOUR TOKEN"
}
}
}

Multiple Tokens

JSON
{
"profile": {
"apn": {
"tokens": ["YOUR TOKEN 1", "YOUR TOKEN 2"]
}
}
}

Override

You can use a provider override to replace what we send to the Apple Push Notifications API or provide an optional data payload for any of the APN alert types.

You can optionally specify if you want to route APN to the development/sandbox account by specifying the isProduction flag. Courier defaults this flag to true

JSON
{
"override": {
"apn": {
"body": {
"apns-priority": "number",
"badge": "Number",
"content-available": "number",
"expiry": "number", // e.g Math.floor(Date.now() / 1000) + 3600 Expires 1 hour from now.
"sound": "String",
"alert": "String or Dictionary", // https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html#//apple_ref/doc/uid/TP40008194-CH17-SW5
"payload": "'{\"messageFrom\":\"Courier\"}'",
"topic": "your-app-bundle-id",
"mutable-content": "number" // 1 will set the flag (default is unset)
},
"config": {
"isProduction": false | true, // defaults to true
"key": "*******",
"topic": "your_app_topic"
}
}
}
}

Everything inside of override.apn.body will replace what we send to the APN API. Values that are not replaced will still be sent.

Tracking Events

Courier will include tracking URL information in the data attribute on the incoming message payload.

See Courier push notification tracking

Was this helpful?