Migrating to FCM from GCM

Updated 15 December 2016

Save

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

to

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.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


8 comments

  • Anmol Arora
    • aastha gupta
  • aastha gupta
  • diti
    • Aastha (Moderator)
  • Alexander Ustinov
    • Aastha (Moderator)
    • aastha gupta
  • Start a Project


      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home