Firebase Cloud Messaging for Android Development
May 7, 2020 /
1. What is Firebase Cloud Messaging (FCM)?
- FCM (Firebase Cloud Message) is a new version of GCM (Google Cloud Message).
- With the help of FCM, easily deliver messages at no cost.
- It is supported by Android, iOs, and Web platforms.
- Firebase messaging is a lightweight, serverless messaging solution built on Firebase Cloud Messaging.
- Send push notifications to all your users anywhere in the whole world using firebase messaging.
2. Android listener service:
- InstanceIDListenerService is required only to access the FCM token.
- Manage the device token to send messages to a single device directly.
- send messages to a device group, subscribe devices to the topic with the server.
3. Additional features of FCM:
- Topic messaging:
- Using Topic Messaging users get a notification in common topics.
- FCM delivers your message to all the devices subscribed to this topic.
- There is no limit on topic messaging.
- The single topic has as many subscribers, or users can subscribe across different topics.
- Firebase Remote Config:
- You change the appearance and behavior of your app without requiring users to download an app update using Firebase Remote Config, and it is a cloud service.
- Firebase Analytics works with other Firebase features.
- Thus, the user can take action on everything from click-through rates to app crashes.
- Easy Implementation:
- Firebase is quick and easy.
- APIs packaged into a single SDK, you can solve customer’s problems without wasting time building complex infrastructure using intuitively.
- Cross-platform support:
- Expand to different platforms without modifying your infrastructure.
4. Firebase Cloud Messaging / FCM Sender ID:
- The equivalent of Google Cloud Messaging (GCM) Sender ID. The path of this id is Firebase > Project > Settings > Cloud Messaging tab.
5. What are the benefits of upgrading to Firebase Cloud Messaging SDK?
- Simpler client development. Users can’t write your own registration or subscription retry logic.
- An out-of-the-box notification solution.
- Anyone sends notifications to target specific audiences based on Firebase Analytics insights using Firebase Notifications, and it is a serverless notifications solution with a web console.
6. What’s new with Firebase Cloud Messaging Service (FCM)?
- New FCM libraries:
- FCM libraries use manifest merging, so you don’t have to worry about permissions.
- It automatically adds any permission, needed to reduce the amount of effort you put in.
- Simplified registration flow:
- Using “Registration Token” as an address, FCM delivers the message to the device.
- This process is now asynchronous.
- On your behalf google library takes token automatically.
- So, when you request to ‘get token’, you get a registered token.
- Send registered token to your servers, and start sending messages.
- All these new improvements apply to both Android and iOS SDKs.
7. Key capability:
- Notification or data messages
- Versatile targeting
- Upstream messages
8. Token problem:
- Where to store the token
- More than one token per user
- What happens when the user logs out
- Keep sending email
9. Notification Payload:
“title”: “Test Notification”,
“body”: “Hello!!! Notification”
- “icon”: Android & iOS
- “sound”: only Android
- “badge”: only iOS
- “click_action”: Android & iOS
10. Data payload:
“title”: “Test Notification”,
“body”: “Hello!! Notification”,
“user_avatar”: “user image”,