How do push notifications work? From your server to a phone
The whole path
A push notification passes through six steps:
- The app asks the user for permission.
- The app registers with the platform's push service and receives a token.
- The app sends that token to your server, which stores it.
- When something happens, your server sends a message and the token to Expo's push service.
- Expo forwards the message to Apple Push Notification service (APNs) or Firebase Cloud Messaging (FCM).
- APNs or FCM delivers it to the device, and the operating system displays it.
The phone only listens to the last link. The device receives notifications from APNs or FCM, and everything before that exists to get a correctly addressed message to them.
What a push token is
A push token is an address. On iOS, the app registers with APNs at launch and receives a device token, which Apple describes as unique to both the device and the app. The app then forwards it to its own server. On Android, the equivalent is an FCM registration token.
Expo adds a layer on top. getExpoPushTokenAsync() returns an Expo push token, and Expo maps it to the underlying APNs or FCM token. This lets one API send to both platforms. Your server stores the Expo push token against the user's device and uses it as the destination.
Expo's library also exposes getDevicePushTokenAsync(), which returns the native APNs or FCM token. That is the token to use when sending through a third-party service or directly to APNs and FCM. When sending through Expo, the Expo push token is the one to store.
Why tokens stop working
Tokens change. Apple's documentation lists three cases where APNs issues a new token: restoring a device from a backup, installing the app on a new device, and reinstalling the operating system. Apple's guidance is to register and receive the token each time the app launches and forward it to the server.
On Android, Firebase considers a registration stale when the device has not connected for over a month, and treats it as expired after 270 days of inactivity. Firebase recommends storing a timestamp with each token and updating it whenever the app uploads the token.
Tokens can also change while the app is running. Expo's notifications library provides addPushTokenListener() for that case.
Sending: tickets and receipts
With Expo, the server sends a POST request to https://exp.host/--/api/v2/push/send. One request can carry up to 100 messages, and Expo applies a rate limit of 600 notifications per second per project.
The immediate reply contains push tickets. A ticket confirms that Expo received the message. It does not confirm delivery.
Delivery status comes from push receipts, which report whether Expo handed the message to APNs or FCM. Expo recommends checking receipts about 15 minutes after sending, and receipts are available for 24 hours.
One receipt error matters more than the others: DeviceNotRegistered. Expo's documentation states that the device can no longer receive notifications and the server should stop sending to that token. Deleting the token at that point keeps the stored list accurate.
Priority and expiry
Two message settings affect delivery. Expo's priority field accepts default, normal or high. Expo states that high-priority messages are usually sent immediately, while normal-priority messages may be throttled and may not be delivered by Apple.
APNs also supports an expiry. When the apns-expiration value is a future date, APNs stores the notification and keeps attempting delivery until that date. When it is 0, APNs attempts delivery once and does not store it. Time-sensitive notifications, such as a delivery that is about to arrive, lose their value if they are delivered hours later.
The operating system shows it, not your app
When the app is in the background or closed, the operating system presents the notification without involving the app's code.
When the app is open, Expo's notifications library does not show incoming notifications by default. The app sets a handler with setNotificationHandler() that decides whether to show a banner, add it to the list, play a sound or set the badge. A missing handler explains notifications that seem to fail during testing with the app open.
Silent pushes
Some notifications are not meant to be seen. On iOS these are background notifications. The payload contains content-available in the aps dictionary and no alert, sound or badge. Apple requires the apns-push-type header set to background and apns-priority set to 5. The system wakes the app in the background, and the app has 30 seconds to do its work.
Apple describes background notifications as low priority. Delivery is not guaranteed, the system may throttle them, and Apple advises sending no more than two or three per hour. They are suited to prompting a refresh, not to anything that must arrive.
In Expo, the contentAvailable field on a message requests this behaviour on iOS.
Practical limits
APNs limits a standard notification payload to 4 KB. Expo states that sending through its push service has no cost, and that it does not store notification contents longer than it takes to deliver them to Apple and Google.
Tokens are best stored per device rather than per user, since one person may have more than one device.
A token table with the user ID, the device's token, the platform and a last-seen timestamp supports all of the above: Firebase's timestamp recommendation, cleanup when a receipt returns DeviceNotRegistered, and sending to every device a user owns.
By default, a request to Expo's push service only needs a valid push token. Expo offers enhanced security in the Expo dashboard, which requires an access token in the Authorization header of every send request, so that only a server holding that token can send to the app's users.
Summary
A push notification travels from your server to Expo, then to APNs or FCM, then to the device, addressed by a token the device obtained. Tokens go stale, a ticket is not a receipt, the operating system presents notifications when the app is not in the foreground, and silent pushes are best effort.
Sources
- Expo docs: Send notifications with the Expo Push Service
- Expo docs: Push notifications FAQ
- Expo docs: Push notifications setup
- Expo docs: Notifications SDK
- Apple docs: Registering your app with APNs
- Apple docs: Pushing background updates to your app
- Apple docs: Sending notification requests to APNs
- Firebase docs: Best practices for FCM registration token management