Migrating to FCM from GCM

As you know Google introduced the new FCM (Firebase Cloud Messaging) as an upgrade to GCM, Its not mandatory to update your app to FCM as the GCM is still functional and the update is not affecting it. But

its recommended to upgrade so that you can get the new features. And for the new apps I’ll recommend¬† to use FCM. So lets start migration our existing android app to FCM.

Firstly import your project to Firebase console and provide the package name and SHA-1. Then download the new google-services.json file and replace it with your existing file in your project.

Please note that now you don’t need any kind of permission in your manifest like in GCM so remove all the GCM related permissions from manifest file. In the app level gradle file change the dependency from


And now all the major changes just replace the code in manifest from

to the new code

The new MyInstanceIDListenerService.java

The FCMListenerService.java

An you are ready to go. All the setup is ready just a little bit change, on the Activity in which you want to create the FCM token in your application just add the code

and the function sendTokenToServer(). And FCM is implemented but don’t forgot that now the API-Key and Sender Key is changed so update them on the server side.

You can also test the application notification from Firebase console as you can directly send message from there. For any assistance you can visit the link.

. . .

Comments (6)

Add Your Comment

  • Anmol Arora
    I’ve already migrated and the new fcm configuration is working fine. But my concern is that I’m not able to send push notification to the GCM registration tokens. When I try sending the push to old gcm registration token through Firebase Console it fails. Can you give any input on that?
    • aastha gupta
      Hi Anmol, please check your Server API key, I guess it must have changed while migrating to FCM. If its changed then you can’t send messages to those GCM tokens from FCM console.
  • diti
    it has another method for sendin api requests, dont use the old url and request data, see the documentation for server request for Firebase, here is an example on server of FCM-server request with PHP:
  • Alexander Ustinov
    It’s cool, but what will be with old apps on GCM?

    Will It work correctly?

    • Aastha
      They will be fine as mostly the Server key (API key) remains same. So you can send notifications to them as well but not from Firebase console.
    • aastha gupta
      They will be fine as mostly the Server key (API key) remains same. So you can send notifications to them as well but not from Firebase console.
  • css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again