Expo
Looking for a way to send push notifications via Expo? This step-by-step tutorial will show you how to integrate Expo’s API the easy way.
Profile Requirements
To deliver a push notification to a recipient over Expo, Courier must be provided the recipient’s Exponent push token. It should be included in the recipient profile as expo
.
Single Token
To push a notification to a single device, you can pass the recipient’s push token as a string to expo.token
.
Multiple Tokens
If the recipient has multiple devices and you’d like to push to all of them, you can pass the push tokens as an array of strings to expo.tokens
.
PROVIDING BOTH TOKEN
AND TOKENS
TO EXPO
If you pass values to both token
and tokens
, Courier will merge the value of token
into the tokens
array and dedupe it.
Override
You can use a provider override to replace what we send to Expo’s API. For example, you can add a ttl value and turn off the sound with your send request:
Everything inside of providers.expo.override
will replace what we send to Expo’s API. Values that are not replaced will still be sent (the title, subtitle, body and data will still be generated and sent in the example above). You can see all the available options by visiting Expo’s website.
Tracking Events
Courier will include tracking URL information in the data
attribute on the incoming message payload.
See Courier push notification tracking
Troubleshooting
Tips for resolving response errors from Expo
Could Not Find APNs Credentials
Excerpt from Expo’s Help Forum on how they handle APN tokens:
Expo push tokens work quite similarly to how Apple’s tokens work with APN’s, since Expo’s server is a relatively thin service that relays notifications to Apple. Expo needs valid APN credentials to send push notifications. And as with APNs in general (not specific to Expo), it doesn’t matter what APNs credentials you had at the time an iOS device provided a device token - the APN credentials just need to be valid at the time of sending the notification.
So, if you revoke your APNs credentials or clear them from Expo, or if your APNs credentials expire (APN p12 certificates expire after one year), Apple will reject all of your push notifications until you provide Expo with valid APN credentials. To be clear, your Expo push tokens and the underlying iOS device tokens are still valid and will still work once you provide new, valid APN credentials.
In this case, the error
Could not find APNs credentials for…
means that Expo does not have any copy of your APNs credentials (currently a p12 certificate). You will need to let Expo recreate the credentials for you (recommended for most developers: runexp build:ios -c
to clear all of them and then runexp build:ios
to let Expo re-provision them) or upload your own credentials from Apple’s developer center (be sure to follow the instructions carefully.
- Your push key should be correctly configured at
https://expo.dev/accounts/[account]/projects/[project]/credentials?platform=ios
- You’ve correctly set your bundle identifier in your configuration
- If you are explicitly passing in the
experienceId
inNotifications.getExpoPushTokenAsync({ experienceId: 'xxxx' })
, make sure it is in the format of@expo_account/expo_projectname