How To Migrate Your Android App From GCM To Firebase
What is GCM?
Google Cloud Messenger (GCM) is a protocol that allows developers to send messages downstream (from servers to apps) and upstream (from apps to servers).
GCM has been deprecated by Google and should no longer be used in your projects.
What is Firebase?
Firebase is a Backend as a Service that removes a lot of necessary server work, which allows developers to focus on the UI.
Firebase Cloud Messaging (FCM) is the replacement for GCM. Put simply, it does about the same thing as GCM, but it is a more modern architecture with additional features.
Why do you need to migrate?
GCM will be shut down in 2019 and will no longer function. If you have an app running on GCM, it’s important to migrate right away in case any issues pop up during the migration process.
When migrating, you’ll need to make changes to the console, client, and server.
Steps to migrate the console:
Fortunately, this is the most simple step and requires no coding.
- Import your current Google Project into the Firebase console.
- Select ‘Add Firebase to your Android App’
- You’ll get a new google-services.json file that you add to the Android application.
Steps to migrate your Android application:
This is where most of the work is done.
- Import the google-services.json from the previous step.
- Change dependency from GCM to FCM in your project’s build.gradle file.
- Remove permissions required by GCM.
- Remove receiver from app manifest.
That’s the bulk of it. You’ll have to go through the rest of your application and remove any code that references GCM.
Steps should to migrate your server:
- In Firebase console, download server account credentials.
- Drag server credentials into your project.
- Replace GCM API key with service account key.
- Update http header to use the new access token.
- Update http endpoint to FCM.
- Re-deploy your server.
The migration is not too difficult, but should certainly be done sooner rather than later to prevent any last minute issues. Google has put together great resources to help you migrate. Check out the Official GCM Migration Guide and a helpful episode from Firecast to assist with your migration.
Need help migrating your Android application? Reach out to us at Broadway Lab.