SDK

Setting up Firebase

Before you can start sending messages to Android, you will have to at least set up a Firebase Cloud Messaging (FCM) project. This is all done via the Firebase Console. This guide walks you through generating the required Service Account JSON file and uploading it to your Actito app settings.

Create a Firebase project

Go to the Firebase console and create a new project. If you already have a Firebase project, you can skip this step.

firebase create project

Check the official Firebase documentation for more information on creating a Firebase project.

Enabling Firebase Cloud Messaging

In Firebase, click on the gear icon next to Project overview and select Project settings. Then, click on the Cloud Messaging tab.

If the Firebase Cloud Messaging API (v1) is not enabled, you will see the following message.

firebase cloud messaging disabled

Click on the 3-dot menu and go to the Google Cloud Platform page to enable it.

firebase cloud messaging enable api

Generate a Service Account

In Firebase, go to the Project overview > Project settings > Service accounts tab and generate a new Service Account for the Firebase Admin SDK.

firebase generate service account

Save the Service Account JSON file somewhere safe. You will need it to configure your Notificare application.

Upload the Service Account JSON file

To configure you Notificare application, open the application in the Dashboard and navigate to the Services section via Menu > Settings > Services.

Click the Configure button on the FCM card.

firebase dashboard fcm card

Then, upload the Service Account JSON file you previously downloaded and click Save.

firebase dashboard upload service file

Upon saving, the service account will appear as follows:

firebase dashboard service account ready

Register your app with Firebase

To use Firebase in your Android app, you need to register your app with your Firebase project. Registering your app is often called "adding" your app to your project.

  1. Go to the Firebase Console.
  2. In the center of the project overview page, click the Android icon or Add app to launch the setup workflow.
  3. Enter your app's package name in the Android package name field.
  4. Click Register app.

firebase register app

Add a Firebase configuration file

Download and then add your app's Firebase config file (google-services.json) to your codebase:

  1. Click Download google-services.json to obtain your app's Firebase config file.
  2. Move your config file into the module (app-level) directory of your app.

To make the values in your google-services.json config file accessible to Firebase SDKs, you need the Google services Gradle plugin (google-services).

  1. In your root-level (project-level) Gradle file (<project>/build.gradle.kts or <project>/build.gradle), add the Google services plugin as a dependency:
plugins {
  id("com.android.application") version "8.13.0" apply false
  // ...

  // Add the dependency for the Google services Gradle plugin
  id("com.google.gms.google-services") version "4.4.4" apply false
}
  1. In your module (app-level) Gradle file (usually <project>/app/build.gradle.kts or <project>/app/build.gradle), add the Google services plugin:
plugins {
  id("com.android.application")
  // ...

  // Add the Google services Gradle plugin
  id("com.google.gms.google-services")
}

Multiple Firebase projects

If your setup uses multiple Firebase projects, typically for development and production, you can use different Firebase configuration files for each environment. Place the Firebase configuration files in the following locations:

  • Production configuration: app/google-services.json
  • Development configuration: app/src/debug/google-services.json

This approach uses Android's build configuration to determine which configuration file to use. You can read more about this approach in the Android documentation.