What is Firebase?

Firebase is Android's new push notifications system, replacing Google Cloud Messaging (GCM).

WonderPush lets you use your own Firebase account. This ensures push token portability letting you change provider, should you wish to do so.

Creating your Firebase account

  1. Go to https://console.firebase.google.com/ and sign in with your Google account.
  2. Check with your team if you do not already have a Firebase account and project.
    You may need to be invited to it if it's not listed.
  3. Click Add project and fill the required information.
309
  1. You can stop here if you do not plan on using Firebase within your application, or you can continue and integrate it.
  2. Add an Android app.
    This will generate a google-services.json file and give you instructions for integrating it in your application.


Locating your Sender ID / Project number

Use this link to get to the Firebase project General settings page of your project.
Alternatively, here's how to reach it:

  1. In your Firebase project console, click the gear icon and select Project settings.
529
  1. In the General tab, under the Your project section, read the Project number:

You can also find this value in the Cloud Messaging tab where it is named Sender ID.

Filling the Firebase credentials in the WonderPush dashboard

You have two options:

  1. Grant IAM permission. In this option, you will grant the WonderPush service account the permission to send Firebase Cloud Messaging notifications to your Firebase project.
    This is the safest option as no private key is ever shared and you will only grant the least privileges, but more clicks are required
  2. Upload a Service Account key. In this option, you will create a Service Account key and upload it to WonderPush.
    The fastest way is to upload a newly generated key for the Firebase Admin SDK service account, although more permissions than necessary are granted.
    (An alternative is to create a dedicated Service Account and grant it the least privileges before generating a new key, but the recommended option is both faster and safer.)

Recommended option: Grant IAM permission

  1. Open your Project Settings in the Firebase Console.
  2. Take note of your Project ID and Project number (aka Sender ID).
  3. Go to the Users and permissions tab and click the Advanced permission settings link below the list.
    This should open the IAM & Admin / IAM page of the Google Cloud Console of the right project. You can check the Project ID in the URL or in the project selector in the top of the page.
  4. Click the Grant access button above the list to open a new panel on the right.
  5. Under Add principals click the text field and type: [email protected]
  6. Under Assign roles click the Select a role selector and type Firebase Cloud Messaging API Admin.
  7. Click the Save button.

📘

Please allow 5 minutes for the permission to propagate.

  1. Go to your WonderPush dashboard, in the Settings / Platforms page, click the Android application section title.

  2. Click the Update Firebase FCM credentials button.

  3. Open the Recommended option: Grant IAM permission collapsible section

  4. Fill your Sender ID (also known as Project number) and Project ID.

  5. Finally click the Save and use WonderPush's service account button.

Alternative option: Upload a Service Account key

  1. Open your Project Settings in the Firebase Console.

  2. Take note of your Project ID and Project number (aka Sender ID).

  3. Go to the Service accounts tab.

  4. Click the Generate new private key button and click the Generate key button in the popup.

  5. Save the generated 〈project-id〉-firebase-adminsdk-xxxxx-xxxxxxxxxx.json file. You will upload it in step 9.

  6. Go to your WonderPush dashboard, in the Settings / Platforms page, click the Android application section title.

  7. Click the Update Firebase FCM credentials button.

  8. Open the Alternative option: Upload a Service Account key collapsible section

  9. Fill your Sender ID (also known as Project number) and upload the service account .json file you have downloaded in step 5.

  10. Your service account now filled, click the Save and use this service account button.

Make your app use your Firebase account

Option 1 - Your app does not use Firebase

If your application does not use Firebase already, don't bother integrating it, you just need to give the Sender ID somewhere in your application.

Configure the WonderPush Android SDK from your app/build.gradle file:

android {
    defaultConfig {
        buildConfigField 'String', 'WONDERPUSH_SENDER_ID', '"YOUR_SENDER_ID"'
    }
}

Replace YOUR_SENDER_ID with your Sender ID.
Just so you know, 1023997258979 is WonderPush default Sender ID.

Option 2 - Your app integrates Firebase

When you integrate Firebase to your application, WonderPush is able to detect the linked Firebase account and use its Sender ID accordingly, so you have nothing to do!

Here is the official guide to integrating Firebase to your Android application.

If you're into details, the google-services.json file that you added to your project contains the Sender ID, and the com.google.gms.google-services plugin that you added to your app/build.gradle creates the corresponding gcm_defaultSenderId string resource to make it available to your app, which WonderPush uses if not already configured otherwise.