The commonplace notifications on our iPhone/Android devices follow an interesting journey.
What is a Push Notification?
A push notification is a message sent to a user. The message is sent even if the app is not in use or the device is offline.
Who Sends the Message?
The app is controlled from a provider service e.g. 500px.com sends you a notification if your pictures are liked. But how exactly 500px server knows your device?
It doesn’t. I am explaining the flow with Apple and the iPhone. Android has a similar flow.
Assuming the app has push notifications and the user has enabled them for the app. after installing an app and logging in, the app requests Apple Push Notification Service (APNS) for a globally unique device token. The token is the unique key for all notifications for the given app and device.
The token is sent to the app’s server (500px.com) and the server stores them. Now, when the server wants to send a push notification to a user device, it creates message payload and sends the request along with the device token to APNS.
The APNS then sends the notification to the device.