Setup
- Go to your Apple Developer Account
- Click “Certificates”
- Click “Keys”
- Click the ”+” button
- Name the Key
- Click “Enable” on “Apple Push Notifications Service (APNs)”
- Click “Continue”
- Click “Register”
- Click “Download”
- Go to the APNS Provider Configuration
- Enter the required information
- Click “Install Provider” or “Save”
Profile Requirements
APNS requires device tokens. You can provide them directly viaapn.token or apn.tokens in the recipient profile, or use a Courier Mobile SDK which syncs tokens automatically and lets you send to a user_id instead.
Getting APNS Tokens
With a Courier Mobile SDK
Using a Courier Mobile SDK is the best way to set this up. All Courier Mobile SDKs sync APNS tokens to Courier and will be automatically managed. This allows you to send pushes directly to auser_id rather than APNS tokens.
Without a Courier Mobile SDK
Follow Apple’s Documentation to setup push notifications on your iOS device. What APNS tokens look like:Sending Messages
This is a common request you can make to thesend API. It shows two APNS provider overrides:
providers.apn.override.body.payloadadds custom data at the payload root, alongside the reservedapsdictionary. Your app reads these keys to do things like open a specific screen when the user taps the notification.providers.apn.override.body.soundandproviders.apn.override.body.badgeset iOS-specific values. Courier compiles theapsdictionary for you from the message content and these overrides.
providers.apn.override.body fields include alert, sound, badge, payload, expiry (a Unix timestamp that defaults to 1 hour after the send), topic, category, threadId, content-available, apns-priority, and apns-collapse-id.
ClickAction and Data Mapping
To pass a click action link into your push notification, enable the data mapping toggle in the Push channel settings.
Data mapping enabled
Sending to a user_id (Recommended)
Silent Messages
Sending to a token
Sending to multiple tokens
Troubleshooting
BadDeviceToken
APNs returns BadDeviceToken when the token you sent does not match any registered device for the environment (production vs. sandbox) you are targeting. Common causes:
- Wrong environment: A token registered against the sandbox environment will fail in production and vice versa. Check the environment toggle in APNS channel settings.
- Stale token: The user uninstalled and reinstalled the app, generating a new token. Update the stored token via the Device Tokens API when your app receives a new registration token.
- Token never registered: The token was never added to a Courier user profile. Ensure your app calls the registration step on every launch.
BadEnvironmentKeyInToken
The key you used to sign the APNs JWT belongs to a different team or bundle ID than the token. Verify that the Team ID and Key ID in your Courier APNS configuration match the app whose tokens you are sending.
Invalid device tokens
When APNs rejects a token, Courier records the outcome so future sends can skip tokens that will never succeed. This status tracking applies to managed tokens (tokens synced by a Courier Mobile SDK). Tokens you pass directly viaapn.token or apn.tokens are used as sent and are not status-tracked.
- APNs rejection reasons
BadDeviceToken,Unregistered,DeviceTokenNotForTopic, andMissingDeviceTokenmark that specific token as failed for that user. The token is skipped on later sends until the device registers a fresh one. - This status is scoped to the individual token and user. It does not affect other users, other tokens, or other channels.
- Managed tokens that have not been refreshed in 60 days are treated as stale and are not used. Courier Mobile SDKs refresh tokens on app launch, so keeping the SDK integrated avoids staleness.
Automatic Courier Mobile SDK Formatting
By default, Courier automatically formats parts of the APNS payload to make a better developer experience for you if you are working with a Courier Mobile SDK. Here you can manage the automatic APNS settings.
- Creates a simple toggle to send to Apple’s production or sandbox push notification environment. Production (switch is on) is used in your production app and Sandbox (switch is off) is used for testing and development. More Details
- “Attach Mutable Content” supports Courier’s iOS Notification Service Extension for better push notification delivery tracking.