Made with heart In heart By  logo-simple Technologies

Migrating from GCM to FCM 2020

firabase-banner

When it comes to driving digital efficiency, three things are required comprising customer engagement, retargeting, and retention. In today’s brutally competitive market, it’s really hard to thrive so. Firebase cloud messaging is a modern tactic that helps brands to remind their subscribed users or customers about their products or services whenever they launch a new product, raise discounts, or want to notify about certain amendments in their services.

FCM (Firebase Cloud Messaging) is a product of Google designed to serve improved user experience whether to implement for Android devices or iOS devices. This is such an amazing trending tool that enables enterprises to gain the attention of their targeted or subscribed users and get them back to their app or website.

What is FCM?

Firebase cloud messaging is an approach to send push notifications to subscribers. It is a product of Google and an updated form or a successor to GCM (Google Cloud Messaging). It acts as a free mobile app tool and web push notifications provider that allows developers to send notifications or message alerts from FCM servers to the users’ device. This helps brands inform the users in real-time about new data, messages, or mails available to sync as it imbibes the approach of streamlining the data from the FCM server to the user’s app

Let’s relate FCM with GCM!

GCM came into existence in the year 2012 with the intention to enable developers to send Android or iOS push notifications to the users’ to help brands ensure user retention. But it was comprising some limitations and hence, deprecated from in the year 2018 Thereby, it’s upgraded version or product ie. FCM was discovered to make a difference.

For instance,

  • FCM made it possible to write the registration.
  • There is no need to explicitly declare the receiver.
  • FCM comes with server-less notifications using the web console.
  • Generating a registration token is taken care of by the library itself.
How FCM Initiates & Comes In Action

FCM leverages a number of credentials to identify and authenticate the app server as well as the client’s app. So, following are the few credentials that are used to authenticate message flow through FCM:

Sender ID
The Sender ID is generated whenever you create your firebase project using a Firebase console to enable notifications for your particular app activities. This Sender ID is used to identify the app server to ensure sending messages to the client app. This Sender ID is created in a numeric form and also considered as your project number

API Key
To connect and access the data from the client app, the API Key gives permission to the Firebase services. This authentication is performed to send seamlessly and smoothly send the data to the client’s app server. This API Key is also referred to as server key or web API Key and this can be in the form of alpha-numeric.

APP ID
The App ID is referred to as the identity or credential of a client app that is registered to receive messages from the firebase console. Again, this will also comprise the alpha-numeric style.

Registration Token
The Registration Token is referred to as FCM identity on the client’s app for a particular device. This Registration token is generated at run-time wherein the app receives the Registration token when it first registers with FCM. In other words, the Registration token is a credential that authorizes an instance of the app running on a particular device to ensure receiving messages from the FCM. This credential may seem a bit long in alpha-numeric.

Backend Process: How FCM Works

Now, let us know how these authentication strings or credentials are leveraged during client app and app servers to communicate through the firebase cloud messaging server.

App Registration Process With FCM
Very first, we need to register the client app with FCM to ensure connection and start messaging. During this registration process, several steps are followed demonstrated well in the image:

firabase-img

Here are the steps to be followed:

To connect with FCM, the client app sends a request to the FCM and this generates a registration token. Meanwhile, the sender ID, App Key, and App ID are shared with FCM.

  • In the next step, FCM returns a registration token to the app.
  • Now, the app forwards the same to the app server.
  • Sending Notification using FCM
firabase-2
Downstream Messaging

Here are the steps when an app server ensures sending a downstream message to the client app. Rest you can see in the above image:

The app server sends a message to the Firebase messaging cloud.

In case, if the client device seems absent, the FCM server stores and keeps the message in a queue to send later. Such messages can be stored for a period of a maximum of 4 weeks.

Once the client device comes in availability, the FCM starts forwarding the messages to the client app on that particular device.

Once the client app receives the messages from the FCM, it instantly starts processing the messaging to seamlessly display the same to their users in the form of notifications in the notification bar.

Topic Messaging

Topic messaging is a tactic that enables an app server to send messages to a multitude of devices opted for a specific topic. Topic messages can also be created and sent leveraging the Firebase Console notification GUI. These messages could be formed in any way. Here FCM handles and takes care of routing and delivery part of topic messages to the subscribed users.

Here are steps followed in topic messaging once the client app gets success in acquiring a registration token:

  • The client app sends a subscribe message to the FCM to subscribe to a topic.
  • The app server starts sending topic messages to FCM to kickstart distribution.
  • FCM starts forwarding the topic messages to the users particularly subscribed to that topic.
Steps To Set Up Firebase Cloud Messaging

If you want to initiate using FCM services in your app, you need to either create a new project first or import the existing one depending on your requirement. All you need to consider these steps to seamlessly create FCM projects for your app. Ensure signing in using your Google account and then, click on “CREATE NEW PROJECT” Or you can opt for “import a Google project” to set up things for your existing project.

  1. Ensure signing in using your Google account and then, click on “CREATE NEW PROJECT”
    Or you can opt for “import a Google project” to set up things for your existing project. step-1
  2. When it comes to creating a project, you will gain a window exhibited below wherein you need to type your project name along with country/region and finally click on “Create Project”. Consider this sample project-creation in the given image:
    step-2
  3. The next step is to set up things in the Firebase Console Overview. You will have three options here, for instance,
    • Add Firebase to your iOS app
    • Add Firebase to your Android app
    • Add Firebase to your Web app
    All you need to click on the suitable option allied to your app device. Here we are considering “Add Firebase to your iOS app” as an instance: step-3
  4. Once you move ahead with your relevant option, you will see the next screen wherein you will be asked about the “package name” of your iOS app. Make sure you are entering the correct package name. The App nickname is optional.

    Moreover, if you are imbibing “dynamic links, invites, or Google Auth., you can also enter the additional information in the “Debug signing certificate SHA-1 which is also an optional part.

    Now, finally click on “ADD APP”. Once you click, you find that that Server API key and Client ID gets generated automatically.

    Meanwhile, this whole information is packaged in one single file (google-service.json) that is automatically downloaded when you click on the Add button. Make sure that you are saving this file securely for future reference.
    final-step

Conclusion

So, this was the detailed guide about Firebase Cloud Messaging from a brief overview of credential usage to process flow. If you want to add your project to the firebase console to drive sustainable user engagement, this blog will truly help you out. You can now send push notification online to test your project.