Apple Push Notifications Service (APNS)
Looking for a way to send push notifications via Apple Push Notifications Service? This step-by-step tutorial will show you how to integrate APNS’s API the easy way.
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”
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 a user_id
rather than APNS tokens.
Mobile SDK | APNS Token Management | Tracking Analytics |
---|---|---|
iOS | Automatic | Automatic |
Android | Not Supported | Not Supported |
React Native | Automatic | Automatic |
Flutter | Automatic | Automatic |
Without a Courier Mobile SDK
Follow Apple’s Documentation to setup push notifications on your iOS device.
What APNS tokens look like:
MANUAL IMPLEMENTATION REQUIREMENTS
You will need to sync, store, and manage your user’s APNS tokens. This likely will require you to create entries in your database, deploy separate endpoints, and add extra development time that can be avoided with a Courier Mobile SDK.
If you’d like Courier delivery and click tracking, you will also need to manually make a request to the trackingUrl
.
Sending Messages
This is a common example request you can make to the send
api that shows:
providers.apn.override.body.aps.YOUR_CUSTOM_KEY
for adding custom data to your payload. This is usually used for opening a specific screen in your app when the user takes action on a push notification.providers.apn.override.body.aps
for applying iOS specific values. You can learn more about these here.
ClickAction and Data Mapping
In order to pass a click action link into your push notification, you will need to enable the data mapping toggle in the Push channel settings.
Data mapping enabled
You can then perform a send request that looks similar to this, passing the clickAction in the data payload.
WARNING PUSH SOUND & BADGING
Sounds and badges can only be configured in the override schema of a send request at this time, and are not compatible with a template
field attached. If your push notifications require sounds and badges, then we recommend shaping your push request with sound
and badge
in the override as shown below.
Sending to a user_id
(Recommended)
Silent Messages
Sending to a token
Sending to multiple tokens
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.
What this setting does:
- 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.