Android: Firebase Credentials

Directions on how to generate a Firebase Cloud Messaging API Credentials for sending Android App Notifications

πŸ“˜

For Android Apps only, not websites

This guide is for developers implementing OneSignal in an Android application for distribution on the Google Play App Store. This guide should not be used for Web Push.

A Google Service Account is a special type of account from Google that applications use to make authorized calls to a variety of APIs, including Firebase Cloud Messaging APIs. For more details, see Google's own documentation on Service Accounts. In order to send push notifications to Android devices, you will need a Service Account to generate a private key for OneSignal to utilize.

Requirements

Setup

1. Create A Firebase Project

Push Notifications require a Firebase Project. If you don't have one set up yet, click Add project and follow the directions to set up your project.

If you already have a FCM project, skip to Step 2.

Page of Projects within Firebase

Page of Projects within Firebase

2. Ensure Firebase Cloud Messaging API (V1) is Enabled

If you've just created a new project, this should already be enabled by default, and you can skip this step. However, if you are using an existing Firebase project, especially an older one, ensure Cloud Messaging API (V1) is enabled.

To check, click the gear icon next to "Project Overview" in the top left of the left-hand menu and select Project settings. Select the "Cloud Messaging" tab.

1230

Firebase gear icon submenu, showing Project Settings

If Firebase Cloud Messaging API (V1) is disabled, then click the kebab menu icon on the top right corner and open the link.

Cloud Messaging API (Legacy) does not need to be enabled as shown here. Only Firebase Cloud Messaging API (V1).

Firebase Cloud Messaging API (V1) is disabled in this image. Ensure it is enabled for your project.

On the subsequent page, click Enable. You may need to wait a few minutes for the action to propagate to Firebase systems.

<https://console.developers.google.com/apis/api/fcm.googleapis.com/overview?project=>\<PROJECT_NUMBER>

Enable Firebase Cloud Messaging API v1.

3. Generate a Private Key JSON file

In Project settings, go to the Service accounts tab.

Click Generate new private key at the bottom of the page.

Service accounts section within Firebase

Service accounts section within Firebase

You'll then see a warning window. Click Generate key.

Generate a FCM v1 Key within Firebase

Generate a FCM v1 Key within Firebase

Save the JSON file somewhere secure. You will need to access it shortly.

4. Configure Your OneSignal App's Android Platform Settings

In OneSignal, navigate to Settings > Platforms > Google Android > Activate

Platforms screen within OneSignal app settings

Platforms screen within OneSignal app settings

Click on Service Account JSON > Choose file and select the JSON file you downloaded from your service account.

FCM configuration screen

FCM configuration screen

🚧

What do if migrating from Legacy FCM settings

If migrating from Legacy FCM settings, you will need to select Firebase Cloud Messaging API (V1) from the dropdown menu before uploading the JSON file.

Click Save and Continue.

Select the SDK you are using for your app development and click Save & Continue.

SDK selection screen

SDK selection screen

Finally, check that you can copy your App ID and check for subscribed users before clicking Save & Continue to complete your setup.

Android configuration installation and testing screen

Android configuration installation and testing screen

πŸ‘

Done!

You now have a key to send push notifications from your app. πŸ₯³

Return to Mobile Push Quickstart


What’s Next