Notifications & Firebase Cloud Messaging (FCM): A Complete Guide
1)What is Firebase Cloud Messaging (FCM):-
Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that
allows you to reliably send notifications and data messages to Android, iOS, and
Web applications at no cost.
In the modern app ecosystem, notifications are the “glue” of user retention.
Whether it’s a breaking news alert, a “your food is arriving” update, or a
personalized discount, FCM acts as the middleman between your server and the
user’s device.
Key Capabilities:
Cross-Platform: Write once, send to iOS, Android, and Web.
Targeting: Send to individual devices, groups of devices, or users subscribed
to specific “Topics.”
Payload Support: Send Notification Messages (handled by the OS) or Data
Messages (handled by your app code).
2)How FCM Works: The Architecture
To understand FCM, you need to see the three main players in the loop:
1. The Client App: (Android/iOS/Web) which receives the message.
2. The FCM Backend: Google’s infrastructure that routes the message.
3. The App Server: Your backend (Node.js, Python, etc.) or the Firebase
Console that triggers the message.
The Lifecycle of a Notification
1. Registration: When a user opens your app, the FCM SDK generates a
unique Registration Token.
2. Token Storage: Your app sends this token to your backend server to be
stored in a database (e.g., Firestore).
3.Sending: When an event occurs (like a new chat message), your server
sends a request to the FCM HTTP v1 API with the target token.
4. Delivery: FCM routes the message to the specific device. If the device is
offline, FCM stores the message and delivers it once the device reconnects.
3)Implementation Guide (2026 Edition)
1. The Frontend Setup
Modern mobile OSs (Android 13+ and iOS) require explicit runtime permissions.
Get Shreyashmane’s stories in your inbox
Join Medium for free to get updates from this writer.
You cannot simply send a notification; you must earn the “Yes.”
Android: You must request POST_NOTIFICATIONS permission.
Web: You need a Service Worker (firebase-messaging-sw.js) to handle
background pushes.
2. Handling the Token
Tokens aren’t permanent. They can change if the user clears app data or reinstalls
the app. You must implement onNewToken to keep your server updated.
Example: Android (Kotlin)
override fun onNewToken(token: String) {
super.onNewToken(token)
// CRITICAL: Update your backend with the new token
sendTokenToServer(token)
}
3. Sending from the Backend
In 2026, the Legacy HTTP API is fully deprecated. You must use the FCM HTTP v1 API, which offers better security via OAuth2.
4)2026 Best Practices: Avoiding the “Uninstall” In 2026, users have lower tolerance for “notification noise” than ever. Research shows that 71% of app uninstalls are triggered by annoying push notifications.
1. Respect “Focus Modes” Both iOS and Android now use AI to summarize notifications. To ensure your message breaks through, use the correct Priority and Channel ID. Only use HIGH priority for time-sensitive alerts (like a security breach or a taxi arrival).
2. Personalization & Segmentation Stop “blasting” your entire user base. Use FCM Topics for interest-based groups.
Bad: Sending a football alert to everyone.
Good: Sending a “Team Scored!” alert only to users who “Follow” that team.
3. Use Data Messages for Silent Logic
Not every FCM message needs to pop a UI. Use Data Messages to sync data in the background or update an in-app badge without bothering the user with a sound or banner.
4. Implement Throttling
If you have 10 million users, don’t send 10 million notifications at exactly 12:00 PM. This “spiky” traffic can lead to delivery delays. Flatten the curve by spreading your sends over a few minutes.
1. The Architecture (Infrastructure Flow)
This is essential for the “How FCM Works” section. It helps developers visualize how the app server communicates with the FCM backend to reach the end device.
2. User Experience (Mobile Notifications)
Use this image to represent the “2026 Best Practices” or the intro. Seeing a notification on a real device makes the technical topic feel more practical and user-centric.
3. The Firebase Console
This image shows the Cloud Messaging dashboard, which is helpful for the part of your guide that mentions sending messages directly from the console without code.





