Android Setup
FCM Setup
The Rover Campaigns app uses Google's Firebase Cloud Messaging to deliver notifications to your app. In order to authorize Rover communication with your app through FCM you will need to create an FCM project and upload its "Server key" to Rover.
Setting up Firebase and Play Services
Head to the Firebase Console and ensure you are logged in with an appropriate Google account for your project. Select "Add a new project", or, if you have already created one, select it.
On the project "Getting Started" page, you can then select "Add Firebase to your Android app".
Fill in your app’s package name and visible name.
Press "Register App". Google will then direct you to download a google-services.json
file, drop it into your Android project’s file tree, and then direct you to add the Firebase SDK to your app’s build.gradle
files.
Build Variants with Different Package Names
If you use separate package names for prod/debug builds, then you can repeat this process to create multiple apps for each package name within the single project. The same google-services.json file will work properly for both.
Connect Rover to Firebase Cloud Messaging
The next step is to connect the Rover web platform to Firebase, to enable Rover to deliver outbound push notifications to your fleet of customer devices.
This involves setting up a Google Cloud Service Account for the Firebase Cloud Messaging service, and then uploading the key file for it (Service Account JSON) to the Rover portal.
If you have previously set this up using an "FCM Server Key", that is the legacy setup and Google now recommends moving to the new Service Account system.
JSON Service Account JSON vs google-services.json
The JSON Service Account file to be uploaded here is distinct from google-services.json
. Google services JSON is the mobile side, and is to be added to the app’s source tree for the Google/Firebase maven plugin to find at build time. It should not be uploaded here as the Android Service Account file to Rover.
Setting up google-servcies.json
is covered in the previous section.
Click on the gear icon adjacent to "Project Overview" and select Project Settings. Then in the Cloud Messaging tab, select "Manage Service Accounts" under the Service Accounts column:
Using the automated Firebase feature for setting up a service account
You may notice a “Service Accounts” tab is available next to the “Cloud messaging” once. However, while a JSON key created in this tab will work, it has an excessively large security scope, greater than Rover needs. We recommend instead following the steps below for a more secure setup.
You will be navigated to the “IAM & Admin” section of the Google Cloud management console. While you would have been navigated directly to the “Service Accounts” section, first, we want to create a role for the Rover SDK to use for push.
Check your Google account selector in the top right
Once you have navigated to the Google Cloud management console, be sure to check that the appropriate Google account is selected in your profile button in the top right, because you have navigated to a separate google site with a different selected-account state.
Select the “Roles” area of the IAM & Admin section of the Google cloud console, then select the “Create Role” button:
Fill out a Title and ID for the new role, and then click the Add Permissions button:
Then, we want to add a single permission to this role, namely cloudmessaging.messages.create
:
Be sure to search for the permission by name in the second field, as the first field is meant for searching for permissions by another role identifier.
Once the permission has been found by searching for it, select it and then ensure the checkbox for it is clicked, and press Add:
Now, we are ready to navigate to the “Service Accounts” area of the IAM & Admin section of the Google cloud console, and create a new Service Account for this role, and generate a new key for it.
Select the “Service Accounts” area, and press the “Create Service Account” button:
Fill out a name and ID for the new service account, and press continue. We’ll assign it to the role shortly after.
In the next screen, “Grant this service account access to project”, type the title of the role you created earlier to find the role:
Then press “Done”.
Once the new Service Account has been created, find it in the list (use the Name column to help), and press the three-dots submenu button. Within, select the “Manage keys” option:
Within, select the “Keys” tab and select Add Key, and within the sub menu select “Create new key”:
Then select the “JSON” file type for the new key:
Then, within the Rover settings, select the Add Android Service account file to replace the deprecated FCM server key:
When complete, your Rover App settings should look like this:
At this point Rover can deliver push notifications meant for your app to FCM. However, to set up your app and the Rover SDK to receive and handle them, you will need to proceed to the next step, Push Notifications.