FCM — what it is, principles of Firebase Cloud Messaging in development

Author: IT Sectr Published: 2026-03-19 Reading time: 8 min

FCM (Firebase Cloud Messaging) is a cross-platform service from Google for delivering push notifications and transferring data between a server and mobile applications. It supports Android, iOS, and web platforms through a single API. According to Firebase Documentation, FCM processes over 1 billion messages daily worldwide.

Key Takeaways

  • FCM is a cross-platform Google service for sending push notifications and data
  • Architecture — the client receives a registration token, the server sends messages through the Firebase Connection Server
  • Message Types — notification (automatic display) and data (full processing in the app)
  • Delivery — FCM uses a persistent connection or priority queues for guaranteed delivery
  • Integration — setup via Firebase SDK, configuring google-services.json, and server configuration

What is FCM?

Firebase Cloud Messaging (FCM) is a cloud service from Google that ensures reliable delivery of push notifications and data messages to mobile devices. Formerly known as Google Cloud Messaging (GCM), FCM has become the primary tool for cross-platform notifications in the Firebase ecosystem.

FCM automatically selects the optimal delivery channel depending on the platform: on Android, it uses its own FCM connection; on iOS, it uses APNS (through the FCM gateway). The developer does not need to implement two different integrations — FCM handles the routing.

The service provides a unified REST API and Admin SDK for sending messages. This allows sending notifications from the server side without being tied to a specific recipient platform.

Key capabilities of FCM

FCM supports several delivery modes: a single message to a specific device, group broadcast by topic, and segmented sending by conditions. Scheduled sending and A/B testing of notification content are also available.

How does Firebase Cloud Messaging work?

The FCM architecture is based on three components: the client application, the Firebase Connection Server, and the app server. The client registers with FCM at startup and receives a unique registration token — a string that identifies the device for the given application.

The app server sends a request to the FCM REST API, specifying the recipient token or topic. The Firebase Connection Server delivers the message using a persistent XMPP connection or HTTP request. If the device is offline, the message is queued and delivered when the connection is restored.

FCM guarantees delivery using priority queues and an acknowledgment mechanism. On Android, the message is stored for up to 28 days in the queue; on iOS, up to 4 weeks (via APNS). After the expiration date, the message is deleted without notification.

FCM token lifecycle

The registration token can change in several cases: when restoring app data, when updating to a new version, or when clearing the cache. The app must implement FirebaseMessagingService.onNewToken to handle token updates and synchronize with the server.

Types of FCM Messages

FCM supports two types of payload: notification and data. Each type determines how and when the message is processed on the recipient device.

ParameterNotificationData
Automatic displayYes, if the app is in backgroundNo, only in the app
HandlingSystem/NOS — in background; app — in foregroundAlways in the app (onMessageReceived)
Maximum size4 KB4 KB
Custom keysLimited to predefined fieldsAny key-value pairs
Requires CollapseKeyOptionalOptional for grouping

In practice, it is recommended to use data messages when the app needs full notification processing in onMessageReceived. Notification messages are suitable for simple scenarios where system display is sufficient.

FCM and APNS: comparing approaches

FCM and APNS are the two main push delivery services. FCM works as a cross-platform gateway, while APNS is only for the Apple ecosystem. Their key differences lie in architecture, certificate requirements, and routing mechanisms.

  • Cross-platform — FCM supports Android, iOS, Web; APNS only iOS, macOS, watchOS, tvOS
  • Authentication — FCM uses Server Key or OAuth 2.0; APNS uses a certificate or Token-based (p8 key)
  • Message priority — FCM has normal/high; APNS has immediate/power-efficient consideration
  • Topics — FCM supports subscription to topics out of the box; APNS requires server logic

The choice between FCM and direct APNS depends on the project architecture. For cross-platform applications, FCM is the optimal choice. For iOS-only projects, direct work with APNS via the HTTP/2 API is acceptable.

When to choose FCM over direct APNS

FCM is justified when the project uses both Android and iOS simultaneously, as well as when Firebase analytics, A/B testing of notifications, or topics without server logic are needed. Direct APNS is preferable for iOS-only applications with minimal dependencies and strict delivery latency requirements.

Integrating FCM in Android

To connect FCM to an Android application, you need to add the Firebase SDK and configure google-services.json in the project root. After token registration, the application is ready to receive messages through FirebaseMessagingService.

kotlin
// build.gradle (Module)
dependencies {
    implementation("com.google.firebase:firebase-messaging:24.1.0")
}

// AndroidManifest.xml
<service android:name=".MyFirebaseMessagingService"
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>

class MyFirebaseMessagingService :
    FirebaseMessagingService() {

    override fun onNewToken(token: String) {
        sendTokenToServer(token)
    }

    override fun onMessageReceived(message: RemoteMessage) {
        message.notification?.let {
            showNotification(it.title, it.body)
        }
    }
}

After setup, the application automatically receives an FCM token on first launch. The token must be sent to the app server for subsequent notification delivery to this device.

Setting up a channel for FCM notifications

On Android 8+, before sending an FCM notification with automatic display, you must create a NotificationChannel. FCM notification messages use the default channel ID, but it is recommended to create a custom channel through FirebaseMessagingService when receiving the first message. Data messages do not require a channel — the app decides itself how and when to show the notification.

Integrating FCM in iOS

On iOS, FCM acts as an intermediary between the app server and APNS. Firebase receives the message from the server, wraps it in APNS format, and sends it through the Apple gateway. The developer needs to configure an APNS key or certificate in the Firebase console.

swift
import FirebaseMessaging
import UserNotifications

class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions options: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        FirebaseApp.configure()
        UNUserNotificationCenter.current().delegate = self

        Messaging.messaging().delegate = self
        return true
    }
}

extension AppDelegate: MessagingDelegate {
    func messaging(
        _ messaging: Messaging,
        didReceiveRegistrationToken fcmToken: String?
    ) {
        UserDefaults.standard.set(fcmToken, forKey: "fcm_token")
    }
}

On iOS, APNS registration happens asynchronously. The FCM SDK automatically obtains the APNS token and passes it to the Firebase server. didReceiveRegistrationToken fires when a new FCM token is received, which combines the APNS token with the project identifier.

Checking delivery status

FCM provides a Firebase console for monitoring delivery: the number of sent, received, and displayed notifications. A status callback is also available via Firebase Cloud Functions for tracking delivery errors on the server side. Key metrics: impressions and opens of notifications.

FCM Best Practices

When working with FCM, it is important to choose the right message type for each scenario. For simple notifications with automatic display, use notification messages. For cases when the app needs to process data before displaying, use data messages. A mixed type (notification + data) is recommended only if the data is needed for analytics rather than changing the notification content.

Manage tokens centrally. Store current tokens on the server in a table linked to the user and platform. Implement a stale token cleanup mechanism: when encountering a NotRegistered or InvalidRegistration error, delete the token from the database. Tokens rarely change, but cleaning them is a mandatory element of FCM support.

Use collapse keys (collapseKey) for grouping messages. If you are sending multiple notifications of the same type (e.g., "currency rate update"), set the same collapseKey. FCM will deliver only the last message from the group, reducing device load and avoiding notification overload for the user.

Monitor delivery through Firebase Console and Cloud Functions. FCM analytics shows the number of sent, received, and displayed notifications. If the display rate is below 70%, check channel settings on Android and permission settings on iOS. Low delivery is often related to disabled channels or notification bans. Fifth: use Firebase A/B testing to optimize notification text and sending time — this increases open conversion by 15–25% according to Firebase data.

Frequently Asked Questions

What is the difference between FCM and GCM?

FCM is the evolutionary update of GCM (Google Cloud Messaging). FCM offers simplified setup through the Firebase Console, built-in analytics, topics, and Web Push support. GCM was officially discontinued in April 2019, and all projects must be migrated to FCM.

How many messages can be sent through FCM for free?

Firebase Cloud Messaging is a free service with no limits on the number of messages. Payment is charged only for using other Firebase services such as Cloud Functions or Firestore. FCM does not require a Spark or Blaze subscription for basic notification delivery.

Why can the FCM token change?

The FCM token changes when: restoring the application from backup, clearing app data, reinstalling, updating to a new version with a changed Sender ID. Always handle onNewToken in FirebaseMessagingService to send the new token to the server.

Does FCM work in China?

Google FCM is blocked in China. Alternative services are used for notification delivery in China: Huawei Push Kit, MiPush (Xiaomi), Oppo Push, Vivo Push. For cross-platform delivery, multi-provider services like Getui are used.

How to check that FCM is configured correctly?

Use the built-in Firebase console: select "Cloud Messaging" — "Send Test Message". Enter a test token and send a notification message. The notification should appear on the device. You can also monitor FirebaseMessagingService.onMessageReceived logs.

Summary

  • FCM is a cross-platform Google cloud service for delivering push notifications and data
  • Token is a unique device identifier used for targeted message delivery
  • Notification is a message type with automatic display by the system in background mode
  • Data is a message type with full payload processed only within the app
  • Topics is a group broadcast mechanism based on subscription to topics without storing tokens on the server
  • APNS gateway — for iOS, FCM acts as an intermediary, forwarding messages through APNS
  • Free — FCM does not charge for the number of sent messages

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.

Discuss the project

Read also