Google Cloud Messaging, now called Firebase (FCM), allows you to send messages to users who have installed your app. This article will walk you through the process of enabling Firebase, entering the proper IDs in the mag+ Publish portal, and then linking the service to your Android app.
Before You Begin..
You should have at least one app created in the Google Play Developer Console. For more information, read the article "Android - Creating an App in the Google Play Developer Console."
Firebase only works for apps that are uploaded to the Google Play Developer Console. If you are building an internally-facing enterprise app (ie. one that will not be made available to the public at large) you must use a workaround to be able to send push notifications to users of your app.
The workaround is to upload your enterprise app to the Google Play Developer Console as an Alpha or Beta test app. As long as the app is not published, users of the Google Play Store will not see it, and you will be able to send push notifications to your internally distributed app.
How to Enable Google Cloud Messaging in Your Android App
This procedure is broken down into three parts:
- Enable Firebase for your app and generate the API key and .json file.
- Enter the API key and .json file in the mag+ Publish portal and enable notifications via FCM.
- Enter the API key in the Google Play Developer Console to link them to your app.
How to Enable Google Cloud Messaging (Firebase) in the Google Developers Console
1. Go to console.firebase.google.com and login to your account.
3. Enter your Project name, click on “Continue”.
The "Project name" can be anything you want to name it, we recommend naming it something similar to your app's name to make it easily identifiable for later if necessary.
4. After the project is created, click the settings "gear" icon in the upper-left and select "Project settings".
6. Fill the Android package name, nickname (optional) and click on “Register app”.
Note: This package name should be similar to the one used in the mag+ publish portal
7. Download .json file and click Next. Similarly, click Next on the next step and skip the last step to complete the process.
How to Configure and Enable Google Cloud Messaging (Firebase) in the mag+ Publish Portal
Before You Begin
- Make sure you have copied the Server key (API key) from the Firebase Console.
- Make sure you have downloaded the .json file from the Firebase Console.
1. Login to the mag+ Publish portal and go to Apps > Android > Build Settings.
Congratulations! You have now successfully enabled Google Cloud Messaging (Firebase) and linked it to your Android app.
Whether this is your first app submission or your app is already live in Google Play, a new .apk file must be generated and uploaded to Google Play to include Google Cloud Messaging in your app.
Note: If you are updating your existing app, be sure to update your build version number before generating a new .apk as mentioned in step 2 of our Android - Updating a Live App article.