Push notifications are messages sent by the server to a mobile device even when the app is closed. According to Google Firebase, 2024, Push notifications are processed through specialized services — FCM on Android and APNS on iOS, which support real-time delivery to millions of devices simultaneously. They have become an integral part of the user experience in modern mobile applications.
Key Takeaways
Push notifications are short messages that the app server sends to the user’s device without an explicit request. They appear as banners, icon badges, or sound signals, attracting the user’s attention to the app and informing them about important events.
A push notification consists of a title, a message body, and optional payload data. Unlike SMS, Push notifications are free for the user and are delivered through cloud service infrastructure — FCM for Android and APNS for iOS. The main goals of Push notifications are: increasing engagement, informing about events, and bringing the user back to the app.
Usage statistics show that properly configured Push notifications increase app retention by 30–60%. However, excessive notification frequency leads to unsubscribes — over 60% of users disable notifications if they are sent more than three times a day.
A Push system includes three components: the app server, the platform service (FCM/APNS), and the client application on the device. The server sends a request to the platform service, which delivers the notification to the target device through a persistent connection with the OS.
The delivery mechanism of Push notifications is based on a persistent connection between the device and the platform service. The operating system maintains an encrypted communication channel through which all Push messages pass.
On first launch, the app requests permission to send notifications and receives a unique device token from FCM or APNS. This token is a string up to 4 KB long that uniquely identifies the app instance. The token changes when the app is reinstalled or the device is restored from a backup.
class FirebaseMessagingService :
FirebaseMessagingService() {
override fun onNewToken(token: String) {
sendTokenToServer(token)
}
override fun onMessageReceived(
message: RemoteMessage
) {
showNotification(message.notification)
}
}
The app server sends an HTTP request to the FCM API or APNS API, specifying the target token, title, body, and additional data. The platform service responds with a delivery status: success, invalid token (the device uninstalled the app), or rate-limited (send frequency exceeded).
fetch("https://fcm.googleapis.com/fcm/send", {
method: "POST",
headers: {
"Authorization": "key=AIzaSy...",
"Content-Type": "application/json"
},
body: JSON.stringify({
to: "device_token_here",
notification: {
title: "New message",
body: "You have a new notification!"
}
})
})
The choice between FCM and APNS depends on the target platform. FCM supports Android and iOS, while APNS supports only the Apple ecosystem. Let’s examine the key differences important for cross-platform mobile app development.
FCM is a Google service running on top of Google Play Services. It supports two delivery schemes: display notifications with automatic rendering and data notifications that the app handles on its own. FCM is free and has no limits on the number of messages sent.
APNS is Apple’s service with support for multimedia attachments (images, video, audio) up to 10 MB. Sending via APNS requires a TLS certificate or authentication key. APNS limits the send frequency to a single device — no more than 150 notifications per minute, after which rate limiting kicks in.
| Characteristic | FCM | APNS |
|---|---|---|
| Platforms | Android, iOS, Web | iOS, macOS, watchOS |
| Requirements | Google Play Services | Apple Developer Program |
| Media | up to 4 KB (data) | up to 10 MB (attachments) |
| Priority | normal/high | immediate/power-saving |
| Cost | free | free (account required) |
Push notifications are classified by display method and purpose. Understanding the types helps choose the right strategy for each user interaction scenario.
The most common type — a displayed notification with a title and body. The OS automatically shows it in the notification shade, on the lock screen, and as a banner. The developer can configure sound, vibration, icon badge, and action buttons for direct actions (reply, open, dismiss).
Data notifications contain only payload without visual display. The app processes them in the background: synchronizes data, updates cache, or triggers downloads. On Android, data notifications are delivered reliably; on iOS, only when the app is active or through background fetch.
Modern mobile OSes support rich and media notifications with images, GIFs, video, and audio. On iOS, this is implemented through UNNotificationAttachment; on Android, through BigPictureStyle and InboxStyle for customizing the notification appearance in the system shade.
Silent notifications are not displayed to the user and are used for background synchronization. On iOS, they have high priority for tasks like updating data before the app is opened. Android treats them as data notifications with minimal priority.
Setting up Push notifications requires actions at the infrastructure, server, and client code levels. Let’s look at the typical process for a cross-platform mobile project.
For Android, you need to create a project in the Firebase Console, add google-services.json to the project, and configure FirebaseMessagingService. The device token is obtained through FirebaseInstanceId or FirebaseMessaging.getInstance().token, after which it is sent to the server via API on first launch or when it changes.
For iOS, you need an Apple Developer Program subscription, creation of a Push certificate or APNS key in the Developer Portal, and enabling the Push Notifications capability in Xcode. Notification registration is done through UIApplication.shared.registerForRemoteNotifications, receiving the deviceToken in AppDelegate.
import UIKit
import UserNotifications
@main
class AppDelegate: UIResponder,
UIApplicationDelegate {
func application(
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken
deviceToken: Data
) {
let token = deviceToken
.map { String.format("%02x", $0) }
.joined()
// send token to your server
}
}
On the server side, Push notifications are sent via REST API or Admin SDK. FCM uses the Firebase Admin SDK (available for Node.js, Java, Python, Go), while APNS uses pusher libraries (pushy for Java, apn2 for Node.js). It is recommended to store tokens in a database with a last-updated timestamp.
Push notification security is critically important, as confidential data may be transmitted through them. Both platforms provide basic protection mechanisms, but the developer must use them correctly.
A Push notification payload may contain personal data of users: names, transaction amounts, message links. Even though the communication channel between FCM/APNS and the device is encrypted, data can be intercepted at the application level if a third-party app intercepts the notification. It is recommended to encrypt sensitive payload on the server using AES-256 and decrypt it on the device using a key stored in Keychain (iOS) or EncryptedSharedPreferences (Android).
The device token is a session identifier that can be compromised if the device is hacked or traffic is intercepted. The app server should validate tokens before sending: check them against the database, track inactive tokens, and remove them on repeated InvalidToken errors. FCM and APNS return InvalidRegistration status for invalid tokens — do not ignore it.
Without frequency control, Push notifications can become a spam tool that annoys users and reduces retention. Set server-side limits: no more than 5 notifications per hour for a single user and no more than 3 identical messages. For transactional notifications (order confirmation, password change), limits can be higher — up to 10 per hour, as they carry critically important information. Use rate limiting at the API send level so an attacker cannot trigger mass notifications through your server.
Frequently Asked Questions
Yes, but direct connection to APNS is not supported on Android — devices without Google Play Services use alternatives like Huawei Mobile Services (HMS) and custom WebSocket connections. However, FCM remains the standard for most apps due to its free cost and reliability.
FCM and APNS store the last notification on their servers and deliver it when the connection is restored. Each device stores only the last notification from each app, so intermediate messages are lost during prolonged network absence.
The most common reasons are an expired Push certificate (valid for 1 year), an invalid device token, disabled notifications in settings, or Low Power Mode enabled. Check the certificate in the Apple Developer Console and ensure the app requests permission through UNUserNotificationCenter.
On Android, use PendingIntent in NotificationCompat.Builder with opening tracking via Intent. On iOS, use the UNUserNotificationCenterDelegate.userNotificationCenter(_:didReceive:withCompletionHandler:) method. FCM provides delivery and open reports for each sent notification.
Minimally — Push notifications do not maintain a constant connection; the OS uses a single system channel for all apps, which minimizes overall power consumption. Frequent sending (every 5 minutes) consumes more energy by waking the device from sleep mode. Silent notifications on iOS consume more battery due to background app activation for processing received data.
Summary
We will develop a mobile application turnkey
IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.
Read also