Mismatch Sender ID issue while migrating from GCM to FCM

Can sender IDs be different for the same Google and Firebase project?

Niharika Arora
Tata 1mg Technology


Yes, It can happen when GCM and FCM are running on different Google cloud projects.

Resolve mismatch sender id issue when migrating from GCM to FCM

In this blog, I am sharing one of the many experiences I had while implementing Push Notifications using Firebase Cloud Messaging(FCM) for 1mg App.

Push Notification and GCM

Push notification is one of the major sources for an application to help engage users better. For this purpose, we started using Google’s Cloud Messaging(GCM) a couple of years ago. There was proper documentation on the Google developer site to include GCM in an application. We made our push services capable of sending notifications based on location, time of the day, special occasions, user actions, app versions and more.

Firebase (FCM)

A few years back we got Firebase Cloud messaging which was capable of doing much more than GCM.

  1. Simplifies client development. You no longer have to write your own registration or subscription retry logic.
  2. Enables a new serverless notifications solution with a web console, the Firebase Notifications console. With the Notifications console, anyone can send notifications to target specific audiences based on Firebase Analytics insights. The console has deep integration with Google Analytics, Firebase predictions, and Firebase A/B testing.

But as our needs were getting fulfilled through GCM, we didn’t migrate to FCM at that time.

GCM Deprecation and Migration from GCM to FCM

Now that GCM has been deprecated, we’ve finally moved to FCM. You can get the documentation here. I started testing my application with FCM using the same sender ID and API key we had for GCM(As per google doc, sender ID will remain same while migrating from GCM to FCM for the same package). I didn’t get the notification on the device. After checking the response on Postman, I got this -


I had no clue where I had made a mistake. I searched on Google, tried different things but in vain.

GCM and FCM on different Google Cloud Projects

We had been running GCM on our first cloud project created some years ago. So when we migrated our GCM project to FCM, all our enhancements were on a different cloud project.

This presented a very tricky situation. FCM and GCM had different sender ids. So, we had to use one token for sending messages to our old users on GCM and another one to send messages to new users on FCM.


What we wanted was to send messages on one key, and receive messages across our entire user base. There was no documented method to do this on Firebase. After several hours of digging, I found a solution. Normally we use this method to generate a firebase token -


But to handle a case where sender IDs are different we can use -

FirebaseInstanceId.getInstance().getToken(“old-sender-id”, FirebaseMessaging.INSTANCE_ID_SCOPE)

The above line of code helps to generate a token from the old sender id (from different could project) and use that to receive messages via FCM.

Please feel free to share your opinion in comments.

If you liked this blog, hit the 👏 . Stay tuned for the next one!



Niharika Arora
Tata 1mg Technology

Googler since 2021 | Ex- Google Developer Expert, Android | Visit : https://thedroidlady.com/ to know more.