Javatpoint Logo
Javatpoint Logo

Firebase Cloud Messaging

Firebase Cloud Messaging

Firebase Cloud Messaging (FCM) is a cross-platform messaging solution which reliably sends the message at no cost. It is formally known as Google Cloud Messaging, which is used for Android, iOS, and web applications.

The service is provided by Google's subsidiary Firebase and on 21 October 2014, Firebase announced that it had been acquired by Google for an undisclosed amount. The official Google Cloud Messaging website demonstrates the Firebase Cloud Messaging (FCM) as the new version of GCM.

If we are using Google Cloud Messaging (GCM) server and client APIs, then there is some bad news, which is that this service has already been removed, and Google plans to discontinue "most" GCM services in April 2019. If we are still using GCM, then we should start migrating our projects to FCM now and complete our migration by April 2019.

Firebase Cloud Messaging

FCM is a free, cross-platform messaging solution which allows us to send push notifications to our audience without worrying about the server code. Using FCM with Firebase's Notification Composer (as seen in the following screenshot), the user can create notifications that target very specific sections of the user base, generally without writing any specific code. Using FCM:

  1. We can send data messages and notification messages.
  2. We can distribute messages for a single device, groups of the device, or for devices subscribed to some topic.
  3. We can send chats, acknowledgments, and other messages from devices back to the server over FCM's battery-efficient connection and reliable channel.

How is FCM differ from GCM?

  1. In FCM, there is no need to write our own registration or subscription retry logic.
  2. There is no need to declare "Receiver" in FCM explicitly.
  3. There is no need to initialize the registration token because the generation of registration token is handled by the library itself.
  4. FCM gives server-less notification solution with web console-Firebase notification. This web console will remind us about the Parse Push console.

How does it work?

FCM implementation contains two main components for sending and receiving. The first one is a trusted environment such as Cloud Function for Firebase or an app server on which to build, target, and send messages, essentially the server-side, and another one is an android client app which receives messages. If we implement our own server code in Cloud Function or Java code, then we can send messages via Firebase Admin SDK or the FCM server protocols.

We can also use the Notification composer for testing or for sending marketing or engagement messages with powerful built-in targeting and analytics.

Implementation path

1) Set up the FCM SDK

Set up Firebase and FCM on our app according to the setup instruction for our platform.

2) Develop our client app

In our client app, we have to add message handling, topic subscription logic, or other optional features. During development, we can easily send text messages from the Notification composer.

3) Develop our app server

We need to decide whether we want to use the Firebase Admin SDK or one of the server protocols to create our sending logic, i.e., logic to authenticate, buildsend requests, handle responses, etc., and build out the logic in our trusted environment.

4) Concerning the development of our own app server

It will give us the basics of the Server environment, but we will not write any code.

Next TopicTypes of Message

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA