The Digital Postman: An In-Depth Guide to How Push Notifications Work on iOS and Android

I. Introduction: The Modern-Day Postal Service

In the digital age, where attention is the most valuable currency, the ability to communicate directly and instantly with users is paramount. Push notifications are the primary mechanism for this communication, serving as the modern-day equivalent of a global postal service. They are the short, direct messages that appear on a device’s lock screen or in its notification center, capable of reaching users even when they are not actively using an application.1 This system is a marvel of engineering, designed for immense scale, efficiency, and reliability. To truly understand its power and nuances, it is helpful to establish an analogy that will guide us through its intricate workings.

Imagine the entire push notification ecosystem as a highly sophisticated postal service. In this system, there are four key actors:

This “push” system stands in stark contrast to older “pull” technologies, where an application would have to constantly ask the server, “Is there anything new for me?” This constant polling is inefficient, draining battery and consuming unnecessary data. The push model is event-driven; the server initiates the communication only when there is something new to say, making it vastly more efficient.2 This report will dissect this digital postal service, from how a user first gets their mailbox key to what happens when the postman arrives at an empty house, providing a definitive guide for developers, architects, and product managers alike.

II. Getting a Mailbox: The Critical First Handshake (Client-Side Registration)

Before any company can send a notification, the user’s device must have a registered address, and the company must know what that address is. This initial handshake, known as client-side registration, is a multi-step process that establishes the secure channel for all future communication. It also reveals a fundamental philosophical difference in how Apple and Google approach user privacy and developer access.

Step 1: The Permission Prompt - Asking for the Mailbox Key

The journey begins with a request for permission, and the manner of this request is the most significant differentiator between the iOS and Android notification experience.

Step 2: The Official Registration - Getting the Unique Address

Once permission is secured (either explicitly on iOS or implicitly on Android), the technical registration process begins.

  1. The client application makes a call to the operating system’s notification framework.

  2. The OS then communicates directly with its native Platform Notification Service (PNS)—APNs for Apple, FCM for Android.4

  3. The PNS generates a unique, opaque, and lengthy alphanumeric string known as the Device Token (or Registration Token in FCM’s terminology).4

This token is the unique address. It identifies a single app on a single device. If the same app is installed on two different phones, it will have two different device tokens. If two different apps are on the same phone, they will also have two different tokens. This token is the cornerstone of the entire targeting system.

Step 3: Informing the Sender - Sending the Address to the Company Server

The PNS passes the newly generated device token back to the client application. The app’s final responsibility in this handshake is to transmit this token to its own backend server.4 The company’s server then stores this token in a database, typically associating it with a specific user’s account or profile.10 This creates the master “mailing list.” When the company wants to send a notification to Jane Doe, its server looks up her user profile, finds the associated device token for her iPhone, and uses that token to address the message.11

This registration process highlights a critical architectural requirement often overlooked in simple implementations: the dynamic nature of the device token. The token is not a “forever” address. It can be refreshed or changed under several circumstances, such as when a user uninstalls and reinstalls the app, restores their device from a backup onto a new phone, or manually clears the app’s data.10 FCM tokens can also expire if a device has been inactive for an extended period, typically 270 days.10

This impermanence means that a company’s server cannot simply collect tokens and assume they will always be valid. A robust system must include logic for managing the entire token lifecycle. When the PNS attempts to deliver a message to a token that is no longer valid (for instance, because the app was uninstalled), it will return an error response to the sender’s server.13 The server must be programmed to listen for these specific error codes and use them as a signal to “prune” the stale token from its database. Failure to do so results in a bloated and inefficient mailing list, where the server wastes resources attempting to send messages to non-existent mailboxes. This not only skews engagement metrics but can also lead to the server being rate-limited by the PNS for repeatedly sending to invalid addresses.10 Therefore, a scalable push notification architecture is not a one-way street; it is a continuous feedback loop where the server actively maintains the health of its token database based on responses from the PNS.

III. The Central Post Offices: A Tale of Two Gatekeepers (APNs vs. FCM)

Once a device is registered, the responsibility for delivery shifts to the massive, complex infrastructure of the Platform Notification Services. While both APNs and FCM serve the same fundamental purpose—acting as a secure and reliable intermediary—they are built with different philosophies and capabilities that reflect the ecosystems they serve.

Apple Push Notification service (APNs): The Walled Garden’s Courier

APNs is Apple’s proprietary and highly integrated service, acting as the single, mandatory gateway for all push notifications destined for Apple devices, including iPhones, iPads, Macs, and Apple Watches.3 Its design emphasizes security, efficiency, and tight control.

Firebase Cloud Messaging (FCM): The Cross-Platform Diplomat

FCM is Google’s comprehensive messaging solution, the successor to the older Google Cloud Messaging (GCM).3 It is designed from the ground up to be a cross-platform service, providing a single, unified API for developers to send messages to Android, iOS, and web applications.8

The primary benefit of this approach is abstraction. A developer with both an Android and an iOS app can build their backend to talk to a single endpoint (FCM) for all notifications, and FCM handles the platform-specific complexities behind the scenes.26

Comparative Table: APNs vs. FCM at a Glance

The strategic choice between using native PNSs or a cross-platform service like FCM depends on an application’s specific needs. The following table summarizes the key differences, providing a clear basis for architectural decisions.

Feature Apple Push Notification service (APNs) Firebase Cloud Messaging (FCM)
Primary Platform iOS, macOS, iPadOS, watchOS, tvOS 16 Android, iOS, Web 3
Permission Model Explicit Opt-In (User must grant permission) 3 Implicit Opt-In (Enabled by default on install) 2
Offline Queuing Policy Coalesced: Stores only the last notification per app 18 Stores up to 100 non-collapsible messages; supports collapse_key 30
Message Expiration Set via apns-expiration header 18 Set via time_to_live (TTL) parameter (default 28 days) 13
Authentication Token-based (.p8 key) or Certificate-based (.p12) 5 Server Keys or OAuth 2.0 Access Tokens 12
Rich Media Handling Requires mutable-content flag and a Notification Service Extension 34 Handled more directly in the payload for Android 3
Advanced Targeting Primarily single-device token targeting 5 Supports single tokens, device groups, and topic-based subscriptions 8

IV. The Company’s Mailroom: Crafting and Sending the Message (Server-Side)

With the user’s address (device token) securely stored, the focus shifts to the company’s backend server—the mailroom where messages are composed, addressed, and dispatched to the Central Post Office (APNs or FCM).

Step 1: Composing the Letter (The JSON Payload)

The “letter” itself is not plain text but a highly structured JSON object known as the payload. This payload contains all the instructions for what the user should see and what the device should do.5

It is crucial to note the strict size limits imposed on these payloads. Both APNs and FCM enforce a maximum size of 4 KB (4096 bytes) for standard notifications.16 APNs allows a slightly larger 5 KB limit for Voice over IP (VoIP) notifications.36 This constraint reinforces a core principle: notifications are for delivering concise alerts and triggers, not for transferring large amounts of data.

Step 2: Stamping and Addressing (The API Request)

Once the JSON payload is constructed, the server wraps it in an HTTP/2 POST request and sends it to the appropriate PNS endpoint (e.g., api.sandbox.push.apple.com:443 for APNs development).18 This request is more than just the payload; it includes a set of critical headers that act as the “stamps” and “addressing information” on the envelope.

Step 3: Handling the Response

After dispatching the request, the server must diligently process the response from the PNS. A successful response code, such as an HTTP 200 OK, does not mean the notification has been delivered to the user’s device. It merely confirms that the PNS has received the request, validated it, and accepted it for delivery.25 The actual delivery is an asynchronous process that happens later.

The most important information often comes from error responses. If the PNS returns an error indicating the device token is invalid or unregistered (e.g., the user has uninstalled the app), this is the explicit signal for the server to remove that token from its active database, thus maintaining the health of its mailing list.4

V. The Magic of Instant Delivery: The Persistent, Power-Sipping Connection

A central question that arises is how millions of devices can remain constantly ready to receive a notification at any moment without their batteries draining within hours. The answer lies not in every app maintaining its own connection, but in a highly efficient, centralized architecture managed by the operating system itself.

The “Always-On” Myth vs. Reality

The notion that every app on a phone is continuously “phoning home” to check for updates is a misconception that would lead to a disastrous user experience. Such a polling-based approach is incredibly inefficient.39 Instead, the mobile OS acts as a single, vigilant gatekeeper.

Upon connecting to a network (Wi-Fi or cellular), the operating system—specifically, core components within iOS or Google Play Services on Android—establishes a single, persistent, and encrypted TCP/IP connection to the servers of its respective PNS.41 This connection is typically maintained over a specific port, such as TCP port 5223 for APNs, with port 443 (standard HTTPS) used as a fallback.41 The key insight is that all push notifications for all apps on the device are funneled through this one OS-managed socket. This consolidation is the foundation of the system’s efficiency, preventing the chaos of hundreds of apps managing their own network connections.39

How it Saves Battery

This centralized, persistent connection is remarkably power-efficient due to a combination of deep software and hardware integration.

This architecture represents a deliberate and fundamental design choice in modern mobile operating systems. In the early days of smartphones, apps had more freedom to run processes in the background. This led to a “tragedy of the commons,” where numerous applications, each trying to maintain its own connection or periodically check for data, would collectively drain the device’s battery. To solve this, platform creators like Apple and Google shifted to a centralized service model. They took on the responsibility of managing the difficult, power-intensive task of maintaining a persistent connection and provided a standardized API for all apps to use. This decision involved a crucial trade-off: it reduced the autonomy of individual developers (who now must use the official PNS as a gatekeeper) in exchange for a vastly superior and more consistent user experience, defined by longer battery life and reliable real-time communication.

VI. Special Delivery Scenarios: The Offline User

A critical test of any delivery system is how it handles a recipient who is not home. In the digital world, this translates to a user whose device is turned off, in airplane mode, or simply without a network connection. The Platform Notification Services have built-in mechanisms for this scenario, but their approaches differ significantly.

The PNS Waiting Room: Queuing Policies

When a PNS attempts to deliver a notification and finds the target device is offline, it does not immediately discard the message. Instead, it places the message in a temporary storage queue, waiting for the device to reconnect.21 The rules governing this queue are a point of major divergence between APNs and FCM.

The Reconnection

When the user’s device is powered on or reconnects to the internet, the operating system’s first orders of business include re-establishing its persistent TCP connection to the PNS. As soon as this connection is live, the PNS detects that the device is back online. It then immediately begins delivering any and all messages that have been stored in its queue for that device’s token, according to the policies described above.13

VII. The Final Mile: Arrival and Display on the Device

Once the notification has successfully traversed the internet from the company’s server, through the PNS, and down the persistent connection to the device, the final stage of its journey begins.

The OS as Receptionist

The operating system is the first to receive the incoming notification payload. It acts as a receptionist, inspecting the payload to identify the target application (via its unique bundle identifier) and assessing the app’s current state.1 This state is the primary factor in determining what happens next.

Display and User Interaction

The visual representation of the notification is handled by the OS and appears in one or more standard locations: as a banner that drops down from the top of the screen, an item on the lock screen, and an entry in the consolidated Notification Center.1 While the core concept is the same, there are subtle user experience differences between the platforms.

Advanced Features: Making Notifications Rich and Actionable

Modern notifications are far more than simple text alerts. Both platforms provide powerful tools to make them more engaging and useful.

This distinction is telling. Apple’s mutable-content approach empowers the client device. The server sends a simple instruction, and the device itself performs the heavy lifting of downloading and processing the media. This aligns with Apple’s long-standing focus on user privacy and on-device computation. Conversely, a feature like FCM’s collapse_key empowers the server and the cloud infrastructure. The server makes a decision about which message is relevant, and the PNS executes that logic in the cloud before the data ever reaches the device. This reflects Google’s core strength in massive-scale, server-side data processing. Developers building cross-platform applications must therefore adopt two distinct mental models: for iOS, they ask, “How can I instruct the device to enrich this notification?”; for Android, they ask, “How can I instruct the cloud to manage the delivery of this notification?”

VIII. Conclusion: Key Takeaways for a Robust Notification Strategy

The journey of a push notification, from a company’s server to a user’s screen, is a complex dance of client-side registration, secure server-to-server communication, and efficient, power-saving persistent connections. Understanding this entire lifecycle is essential for building an effective and reliable messaging strategy. The analysis yields several critical takeaways.

Works cited

  1. What are push notifications? - Adjust, accessed October 26, 2025, https://www.adjust.com/glossary/push-notification/

  2. Everything You Need to Know About Push Notifications - HUSPI, accessed October 26, 2025, https://huspi.com/blog-open/what-is-a-push-notification-and-how-does-it-work/

  3. Push Notifications on iOS vs Android: the Key Differences - MobiLoud, accessed October 26, 2025, https://www.mobiloud.com/blog/push-notifications-ios-vs-android

  4. How push notifications work on Apple and Android - Knock.app, accessed October 26, 2025, https://knock.app/blog/how-push-notifications-work-on-apple-and-android

  5. Apple Push Notification Service (APNs) - 4Js, accessed October 26, 2025, https://4js.com/online_documentation/fjs-fgl-3.00.05-manual-html/c_fgl_mobile_push_notif_apns.html

  6. Do Push Notifications Really Drain the Battery? - MobiLoud, accessed October 26, 2025, https://www.mobiloud.com/blog/push-notifications-battery

  7. What is Apple Push Notification Service (APNs) in 2025? - Scalefusion Blog, accessed October 26, 2025, https://blog.scalefusion.com/apple-push-notification-service-apns/

  8. Firebase Cloud Messaging - Wikipedia, accessed October 26, 2025, https://en.wikipedia.org/wiki/Firebase_Cloud_Messaging

  9. Push Notification with FCM (High-Level Architecture) & Key Considerations - Medium, accessed October 26, 2025, https://medium.com/@balichowdry/push-notification-with-fcm-high-level-architecture-key-considerations-df60369307c0

  10. Best practices for FCM registration token management | Firebase Cloud Messaging - Google, accessed October 26, 2025, https://firebase.google.com/docs/cloud-messaging/manage-tokens

  11. How Firebase Cloud Messaging (FCM) Works in Android: A Detailed …, accessed October 26, 2025, https://medium.com/@YodgorbekKomilo/how-firebase-cloud-messaging-fcm-works-in-android-a-detailed-system-design-5d937f52b033

  12. Why Most Mobile Push Notification Architecture Fails (And How to Fix It) - Netguru, accessed October 26, 2025, https://www.netguru.com/blog/why-mobile-push-notification-architecture-fails

  13. Life of a message from FCM to the device - The Firebase Blog, accessed October 26, 2025, https://firebase.blog/posts/2019/02/life-of-a-message/

  14. Understanding message delivery | Firebase Cloud Messaging - Google, accessed October 26, 2025, https://firebase.google.com/docs/cloud-messaging/understand-delivery

  15. Push Notifications at Scale: From 100 to 10 Million Users | by Karishma Agrawal | Sep, 2025, accessed October 26, 2025, https://proandroiddev.com/push-notifications-at-scale-from-100-to-10-million-users-975589ec4a29

  16. Apple Push Notification service - Wikipedia, accessed October 26, 2025, https://en.wikipedia.org/wiki/Apple_Push_Notification_service

  17. Apple Push Notification service (APNs): Overview - Hexnode, accessed October 26, 2025, https://www.hexnode.com/blogs/apns/

  18. Sending notification requests to APNs | Apple Developer Documentation, accessed October 26, 2025, https://developer.apple.com/documentation/usernotifications/sending-notification-requests-to-apns

  19. Establishing a connection to Apple Push Notification service (APNs), accessed October 26, 2025, https://developer.apple.com/documentation/usernotifications/establishing-a-connection-to-apns

  20. iOS Push Notification Setup Guide - Userpilot Knowledge Base, accessed October 26, 2025, https://docs.userpilot.com/developer/installation/mobile/ios-push-notification-setup-guide

  21. Setting up a remote notification server | Apple Developer …, accessed October 26, 2025, https://developer.apple.com/documentation/usernotifications/setting-up-a-remote-notification-server

  22. FCM (Firebase Cloud Messaging) - PubNub, accessed October 26, 2025, https://www.pubnub.com/learn/glossary/fcm-firebase-cloud-messaging/

  23. Firebase Cloud Messaging, accessed October 26, 2025, https://firebase.google.com/docs/cloud-messaging

  24. FCM Architectural Overview | Firebase Cloud Messaging - Google, accessed October 26, 2025, https://firebase.google.com/docs/cloud-messaging/fcm-architecture

  25. How Push Notification Delivery Works Internally: APNs and FCM Deep Dive - Clix Blog, accessed October 26, 2025, https://blog.clix.so/how-push-notification-delivery-works-internally/

  26. iOS Push Notification: Backend Choice - APNs vs. FCM? : r/iOSProgramming - Reddit, accessed October 26, 2025, https://www.reddit.com/r/iOSProgramming/comments/1l1orqj/ios_push_notification_backend_choice_apns_vs_fcm/

  27. Get started with Firebase Cloud Messaging - Google, accessed October 26, 2025, https://firebase.google.com/docs/cloud-messaging/get-started

  28. iOS Messaging Setup | React Native Firebase, accessed October 26, 2025, https://rnfirebase.io/messaging/usage/ios-setup

  29. Receive all the push notifications when devices are offline - Stack Overflow, accessed October 26, 2025, https://stackoverflow.com/questions/52522362/receive-all-the-push-notifications-when-devices-are-offline

  30. Comparison - Apple Push Notification Service (APNS), Google Cloud Messaging (GCM), Firebase Cloud Messaging (FCM) and Windows Notification Service (WNS) - Hexnode UEM, accessed October 26, 2025, https://www.hexnode.com/blogs/comparison-apple-push-notification-service-apns-gcm-fcm-wns/

  31. Non-collapsible and collapsible messages | Firebase Cloud Messaging - Google, accessed October 26, 2025, https://firebase.google.com/docs/cloud-messaging/customize-messages/collapsible-message-types

  32. What Happens with Push Notifications When a Device Is Offline? - Alertzy, accessed October 26, 2025, https://alertzy.app/articles/what-happens-with-push-notifications-when-a-device-is-offline

  33. Your server environment and FCM | Firebase Cloud Messaging, accessed October 26, 2025, https://firebase.google.com/docs/cloud-messaging/server-environment

  34. Modifying content in newly delivered notifications | Apple Developer Documentation, accessed October 26, 2025, https://developer.apple.com/documentation/UserNotifications/modifying-content-in-newly-delivered-notifications

  35. Send an image in the notification payload | Firebase Cloud Messaging - Google, accessed October 26, 2025, https://firebase.google.com/docs/cloud-messaging/ios/send-image

  36. Generating a remote notification | Apple Developer Documentation, accessed October 26, 2025, https://developer.apple.com/documentation/usernotifications/generating-a-remote-notification

  37. Custom push payloads - Customer.io Docs, accessed October 26, 2025, https://docs.customer.io/journeys/push-custom-payloads/

  38. Send Messages using Firebase Console, accessed October 26, 2025, https://firebase.google.com/docs/cloud-messaging/send/firebase-console

  39. How does persistent tcp/ip connections preserve battery and lower bandwidth usage?, accessed October 26, 2025, https://stackoverflow.com/questions/19111901/how-does-persistent-tcp-ip-connections-preserve-battery-and-lower-bandwidth-usag

  40. www.mobiloud.com, accessed October 26, 2025, https://www.mobiloud.com/blog/push-notifications-battery#:~:text=They%20operate%20on%20efficient%20connection,picked%20up%20by%20the%20device.

  41. Configure devices to work with APNs - Apple Support, accessed October 26, 2025, https://support.apple.com/guide/deployment/configure-devices-to-work-with-apns-dep2de55389a/web

  42. What technology does the iOS Apple Push Notification Service (APNS) use to maintain a persistent connection with each device to receive such fast push notifications? - Quora, accessed October 26, 2025, https://www.quora.com/What-technology-does-the-iOS-Apple-Push-Notification-Service-APNS-use-to-maintain-a-persistent-connection-with-each-device-to-receive-such-fast-push-notifications

  43. How are Apple devices maintaining persistent connections with Apple servers for things such as APN, FindMy network, etc - Ask Different - Apple StackExchange, accessed October 26, 2025, https://apple.stackexchange.com/questions/436553/how-are-apple-devices-maintaining-persistent-connections-with-apple-servers-for

  44. How to test if iPhone keeps persistent connection to push notification service? - Reddit, accessed October 26, 2025, https://www.reddit.com/r/HomeNetworking/comments/1lc36vz/how_to_test_if_iphone_keeps_persistent_connection/

  45. I stood one of these up last year to play around with it. It works flawlessly bu… - Hacker News, accessed October 26, 2025, https://news.ycombinator.com/item?id=28888630

  46. Heartbeat Mechanism, accessed October 26, 2025, https://docs.oracle.com/cd/E19206-01/816-4178/6madjde6e/index.html

  47. Heartbeat (computing) - Wikipedia, accessed October 26, 2025, https://en.wikipedia.org/wiki/Heartbeat_(computing)

  48. Push technology - Wikipedia, accessed October 26, 2025, https://en.wikipedia.org/wiki/Push_technology

  49. Rretry mechanism of push notification to offline mobile phone - Microsoft Q&A, accessed October 26, 2025, https://learn.microsoft.com/en-us/answers/questions/313795/rretry-mechanism-of-push-notification-to-offline-m

  50. Adding collapse_key in FCM - Stack Overflow, accessed October 26, 2025, https://stackoverflow.com/questions/39886108/adding-collapse-key-in-fcm

  51. Enhancing iOS Push Notifications with Notification Service Extensions: Overcoming Real-World Challenges | by Sirsha Banerjee | Medium, accessed October 26, 2025, https://medium.com/@_.sirsha/enhancing-ios-push-notifications-with-notification-service-extensions-overcoming-real-world-8b71186b54e1