Android FCM Credentials

On Android, Teak sends push notifications through Firebase Cloud Messaging (FCM). Setting this up has two halves:

  1. Connect your game’s project to a Firebase project so the app can receive messages.

  2. Hand Teak the FCM credentials it needs to send messages on your behalf.

We’ll do the project side first, then copy the credentials into Teak.

Firebase is required for Teak push notifications on Android. If your game doesn’t already use Firebase, you’ll add it in the steps below: connecting your app to a Firebase project (google-services.json + the Google Services Gradle plugin) here, then adding firebase-messaging alongside Teak’s other dependencies in the next step.

Add Firebase to your Android Project

If your game is already connected to a Firebase project, you can skip ahead to Connect Your Credentials to Teak.

  1. Open the Firebase Console and create a project for your game, or open the existing one.

  2. In the project, click the Android icon to register an Android app. Enter your app’s package name (the applicationId from your app-level build.gradle). The nickname and debug signing certificate are optional.

  3. Download the generated google-services.json file and place it in your app module directory (the app/ folder, alongside its build.gradle).

  4. Add the Google Services Gradle plugin so the build picks up google-services.json.

    In your project-level build.gradle (or settings.gradle if you use the plugins block), declare the plugin:

    plugins {
      // ... other plugins
      id 'com.google.gms.google-services' version '4.4.2' apply false
    }

    Then apply it in your app-level build.gradle:

    plugins {
      id 'com.android.application'
      id 'com.google.gms.google-services'
    }
    Google occasionally bumps the plugin version. For the authoritative, current steps, see Firebase’s own Add Firebase to your Android project guide. You do not need to add the Firebase SDK dependencies it lists — firebase-messaging is covered as one of Teak’s own required dependencies in the next step.

With your app connected to Firebase, you can copy the credentials over to Teak.

Connect Your Credentials to Teak

Firebase Cloud Messaging (v1) Credentials Guide

In order to send notifications to your game on Android, Teak needs your Firebase Cloud Messaging (FCM V1) credentials.

In this guide, we’ll download a Service Account Key (in JSON format), and copy the Sender ID value from your Firebase console, and input those into Teak.

You will need the following accounts to complete this step:

  • An account on the Firebase Console with an Editor or Owner role and access to your game

  • An account on Teak with access to your game

Open Project Settings  Cloud Messaging in your Firebase project.

  1. Go to your Firebase Console and open the project for your game. This must be the same project that you are using to authenticate the Firebase SDK in your game.

    If you need to confirm that you have the correct Firebase project: Open the google-services.json file from your project and find the project_number. Confirm that the value matches the Sender ID value on the Cloud Messaging tab.

  2. Click the gear icon in the upper left corner, and click Project settings.

    firebase dashboard

  3. Click on the Cloud Messaging tab.

Enable Firebase Cloud Messaging API (V1), (if it isn’t already enabled).

  1. Make sure that Firebase Cloud Messaging API (V1) is enabled. Support for FCM (Legacy) will be discontinued by Google on June 20th, 2024.

    Enabling Firebase Cloud Messaging API (V1)

    If the V1 API isn’t enabled, proceed with these steps to activate it.

    1. In the Firebase Cloud Messaging API (V1) section, click on the 3 vertical dots. ⋮

    2. Click Manage API in Google Cloud Console.

    3. In the new tab that opens, click Enable.

    4. This will load the API/Service Details page. After the page has loaded, close this tab.

    5. Return to the Firebase Console page and refresh the page.

    6. Firebase Cloud Messaging API (V1) should now be enabled.

    firebase notification settings

Copy the Sender ID to Teak

  1. In the Teak Dashboard for your game, navigate to Settings  Android.

  2. Click Setup Firebase Cloud Messaging (V1) to open the FCM setup modal.

  3. Copy Sender ID from Firebase to the FCM Sender ID field in the setup modal for Teak.

Leave this modal open for the next step.

Generate a Service Account Key in Firebase

  1. Back in the Firebase dashboard, click the Service accounts tab.

    firebase service accounts

  2. By default, the Firebase Admin SDK service account will be selected. This is fine for most cases.

  3. Click the Generate new private key button and confirm you want to Generate key in the popup. This will download a private key as a JSON file.

Upload the Service account private key to Teak

  1. Return to the Teak dashboard. The FCM setup modal should still be open.

  2. Click the Select private key file (JSON) and locate the private key

  3. Click Save to confirm your changes.

With that setup complete, we’re ready to install the Teak SDK.

Amazon Fire Devices

If you also ship to Amazon Fire devices, those use Amazon Device Messaging (ADM) rather than FCM. The Teak SDK’s manifest entries for ADM (services, receivers, and permissions) are already bundled in the AAR and merge into your app automatically — there’s nothing to add there.

What you do need is Amazon push credentials: Finding your Amazon Device Messaging Credentials. Store the resulting API key as assets/api_key.txt in your app module, per Amazon’s Store Your API Key as an Asset guide.