Programming
We provide developers and engineers the guides and tutorials they...
Search
We provide developers and engineers the guides and tutorials they...
Content is king. It's not just about how you're going to write, b...
Looking for an engaging connection with thousands of other people...
How push notifications work: device tokens, APNs and FCM, queues and workers, user preferences, rate limits, retries and deduplication at scale.
Quick answer: Your phone keeps one persistent connection open to its platform's push service: APNs (Apple Push Notification service) on iPhones and FCM (Firebase Cloud Messaging) on Android. When an app is installed, it gets a device token from that service and sends it to the app's backend. To notify you, the backend sends a message and the token to APNs or FCM, which delivers it down that existing connection and wakes the app or shows the alert. At scale, the backend is a pipeline: events go into a queue, workers apply user preferences and rate limits, render the message, and send it through the right channel with retries.
If every app kept its own connection to its own server, a phone with 80 apps would hold 80 connections and the battery would be flat by lunchtime. Mobile operating systems also suspend apps in the background.
So the operating system maintains one shared, efficient connection to its vendor's push service, and every app's notifications travel through it. For web browsers, the equivalent is the Push API, which delivers messages to a service worker even when the site is closed.
A user can have several devices, so there may be several tokens. Tokens change: after reinstalling, restoring a backup, or sometimes after an update. The backend must update them and discard old ones.
Because delivery is not guaranteed, a notification should be a prompt to open the app, not the only copy of important information. The FCM documentation describes message types, priorities and delivery behaviour in detail.
A real product sends more than push: also email, SMS and in-app messages. A dedicated notification service handles them all behind one interface.
1. Trigger. Another service publishes an event or calls the API: "order 123 shipped, notify user 42".
2. Enqueue. The request goes into a message queue. The calling service returns at once and is unaffected by slow providers.
3. Decide. A worker picks it up and checks:
4. Render. Fill a template with the user's name, language and details.
5. Fan out. Create one send task per device token and channel.
6. Send. Channel-specific workers call APNs, FCM, an email service or an SMS gateway.
7. Track. Record the outcome: sent, failed, delivered, opened.
Email follows its own long path after this point; see how email works.
A breaking-news alert or a marketing campaign targets millions of devices at once.
When the app is open, it often has its own connection to your servers, typically a WebSocket, and updates arrive through that. Push providers are for when the app is closed or in the background. Many systems send through both and let the app suppress the duplicate.
The technical system is only half of a good notification service.
People who feel spammed turn notifications off entirely, or uninstall the app. Restraint keeps the channel useful.
An identifier issued by Apple's or Google's push service for one app on one device. Your server uses it as the address for sending notifications.
APNs is Apple's push service for iOS, macOS and related devices. FCM is Google's service for Android, and it can also relay to APNs and web browsers.
No. They are best effort. Devices may be offline, users may disable them, and providers may drop or collapse messages.
Usually a retry without deduplication, or the same alert sent through two channels or to two registrations of the same device.
Push notifications work because every phone keeps a single connection to its platform's push service, and apps address devices by token. Around that sits an ordinary but carefully built pipeline: queue the request, check preferences, render, fan out, send with retries, and clean up dead tokens. The engineering challenge is volume; the product challenge is sending only what people want.