Migrating from Google Cloud Messaging to Firebase Cloud Messaging

This is a guide to migrate your application from using Google Cloud Messaging to Firebase Cloud Messaging, or to deploy a fresh Firebase Cloud Messaging application.

Migration step:

(This guide is based on an article written by Google)

  • Importing Google Cloud Messaging project to Firebase

Screen_Shot_2017-04-10_at_2.34.57_PM.png

  • In the Firebase console, select Import Google Project.
  • Select your GCM project from the list of existing projects and select Add Firebase.
  • In the Firebase welcome screen, select Add Firebase to your Android App.
  • Provide your package name and SHA-1, and select Add App. A new google-services.json file for your Firebase app is downloaded.
  • Select Continue and follow the detailed instructions for adding the Google Services plugin in Android Studio.

You can replace step 1 by creating a new Firebase project on your own, if you don’t have an existing GCM project. But remember, the package name MUST match with the package name of your application declared in your AndroidManifest.xml:

Screen_Shot_2017-04-10_at_1.06.51_PM.png

 

The package name is always declared in the beginning of the manifest file, like this:

Screen_Shot_2017-04-10_at_1.36.03_PM.png

  • Download the google-services.json file in the Firebase console after you create your project from step a, and move that file to YOUR_APP_FOLDER/app. Here, YOUR_APP_FOLDER is the folder where you store your application, for example, /Users/yourname/AndroidStudioProjects

  • Adding Fire dependencies and removing GCM dependencies
    • Add the following to the end of app-level build.gradle, and the dependencies to support Firebase:


Screen_Shot_2017-04-10_at_4.39.56_PM.png

  • Add the following to the project-level build.gradle’s dependencies:

    Screen_Shot_2017-04-10_at_1.25.50_PM.png
  • Remove the following permissions from AndroidManifest.xml:

Screen_Shot_2017-04-10_at_1.23.18_PM.png

  • Uploading API Key to Skillz. Screen_Shot_2017-04-10_at_4.48.59_PM.png

    • Select Cloud messaging tab
    • You will see the server key, copy the server key
    • Go to developers.skillz.com and then go to your application
    • Select the Push Notification tab on your left
    • In the Android - GCM Push notification, paste your server key to the blank text field, and hit Save:

Screen_Shot_2017-05-12_at_10.51.14_AM.png