The offline problem
When a user closes the app there is no open connection to push to. Push notifications solve this by handing the message to a platform gateway that the operating system keeps a connection to, even when your app is closed.
The token flow
- On install, the app registers and receives a device token from the platform.
- Your server stores the token mapped to the user.
- To notify, your server sends the message plus the token to the platform gateway, which delivers it to the device.
Important realities
- Delivery is best effort. The gateway may drop messages and gives no strong guarantee.
- Tokens expire or become invalid; the gateway reports stale tokens you must prune.
- A user may have many devices, so one notification can mean several gateway calls.
Practical care
- Respect platform rate limits and payload size caps.
- Use a priority flag so urgent alerts wake the device while routine ones batch.
Key idea
Push notification architecture reaches offline devices by sending a message and a device token to a platform gateway, accepting best effort delivery and pruning the stale tokens the gateway reports.