Mobile Networking · Mobile Data Under the Hood · Lesson 4 of 4
How Push Notifications Arrive
How one always-on connection delivers alerts for every app on your phone.
Apple Push Notification Service
A chat message pops up on your locked iPhone within seconds. Your phone didn't check the chat app's server. If every app kept its own connection open, your battery would drain fast. Instead, the iPhone keeps one persistent connection to Apple's servers and every app shares it.
That service is APNs, the Apple Push Notification service. Don't confuse it with the APN from the first module. Here's how a message travels.
- When the app is set up, the phone gets a device token that identifies that app on that device. The app sends the token to its own server.
- When there's news, the app's server sends the message and the token to APNs.
- APNs pushes it down the connection your phone already has open.
Apple says devices reach APNs on TCP port 5223, and fall back to port 443 if 5223 is blocked. So on a strict network that blocks 5223, notifications can still get through over 443.
Apple handles every notification, so it sees which app sent one and when. Unless the app encrypts the message, it can see the text too.
Firebase Cloud Messaging on Android
On Android phones with Google Play services, Firebase Cloud Messaging (FCM) does the same job. The phone keeps one long-lived connection to Google's servers, and every app that uses FCM shares it. Each app install gets a registration token, which works like Apple's device token.
Google's network guide says this connection uses TCP ports 5228, 5229 and 5230, and sometimes 443. It also asks networks that use NAT, including carriers running CGNAT, to keep these connections open for at least 30 minutes when idle. Otherwise the phone has to keep waking up to reconnect, which costs battery.
Push services hold useful records. In December 2023, a US senator revealed that governments had been asking Apple and Google for push notification data. A token can be linked to an account, and the records show which apps sent alerts and when. Apple then said it would require a judge's order, which Google already did.
To limit what the push service sees, a privacy-focused app can send only a short, empty wake-up signal. The phone then fetches the real message directly from the app's own server.
Can you answer these?
- Which TCP port do Apple devices normally use to connect to APNs?
- Why do Android apps share one FCM connection instead of each keeping its own?
Answer them in the app to earn 70 XP (Pro).
Answer in the app