logo
Firebase - Interview Questions and Answers
How does Firebase Cloud Messaging (FCM) work?

Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that allows developers to send notifications and messages to Android, iOS, and web applications. Here’s how it works:

1. Message Flow
  • App Registers with FCM: The client app (Android/iOS/Web) registers with FCM and receives a registration token.
  • Server Sends a Message: The backend server sends a message to FCM, specifying the target device or topic.
  • FCM Delivers the Message: FCM routes the message to the correct device, ensuring reliable delivery.
2. Types of Messages
  • Notification Messages: Display messages automatically in the system notification tray.
  • Data Messages: Deliver custom data payloads to the app for background processing.
3. Key Features
  • Topic Messaging: Send messages to multiple users subscribed to a specific topic.
  • Device Targeting: Send messages to specific devices using their registration tokens.
  • Condition Messaging: Use logical expressions to target multiple user segments.
  • Scheduled & Prioritized Delivery: FCM allows setting priorities and conditions for message delivery.
4. Architecture
  • Client App: Receives and handles messages.
  • FCM Backend: Routes and manages message delivery.
  • Application Server: Triggers and sends messages using FCM APIs.
5. Delivery Mechanism
  • On Android, FCM uses Google Play Services for efficient delivery.
  • On iOS, it integrates with APNs (Apple Push Notification Service).
  • On Web, it uses Web Push protocols.