Start a Project

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

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.

Exit mobile version