Enable Firebase Cloud Messaging

Prev Next

Overview

To enable push messaging functionality for the Mapp Engage Android SDK (v6 or v7), you must integrate Firebase Cloud Messaging (FCM). This section guides you through setting up Firebase and connecting it to your app.


Setup Steps

Step 1: Set Up Firebase in the Developer Console

  1. Log in to the Firebase Developer Console.

  2. Click "Create a Project".

  3. Enter a Project Name. While any name is acceptable, it is recommended that you use something relevant to your app for easier identification.

  4. Review the configuration and continue with creating the project.

  5. Link an existing Google Analytics account or create a new one.

  6. The project has been created.

  7. After the project is created, go to Project Settings by clicking the gear icon in the top left corner.

  8. Navigate to the Service Accounts tab, and click "Generate new private key". This will download a JSON file containing the private key. This service account key is required when configuring the Android channel in Mapp Engage.


Step 2: Integrate Firebase with Your Android App

  1. In the Firebase Console, register your Android app by providing the package name.

  2. Download the google-services.json file and place it in the root directory of your Android app module.

  3. Update Your Gradle Files: To make the google-services.json values accessible to Firebase SDKs, you'll need to add the Google Services Gradle plugin to your project.

    • Root-level (Project-level) build.gradle.kts file:

      id("com.google.gms.google-services") version "4.4.2" apply false
    • Module-level (App-level) build.gradle.kts file:

      Note

      Use the latest compatible Firebase BoM version according to your project setup.

      plugins {
        id("com.android.application")
      
        // Add the Google services Gradle plugin
        id("com.google.gms.google-services")
      
        ...
      }
      
      dependencies {
        // Import the Firebase BoM
        implementation(platform("com.google.firebase:firebase-bom:YOUR_VERSION"))
      
      
        // TODO: Add the dependencies for Firebase products you want to use
        // When using the BoM, don't specify versions in Firebase dependencies
        implementation("com.google.firebase:firebase-analytics")
      
      
        // Add the dependencies for any other desired Firebase products
        // https://firebase.google.com/docs/android/setup#available-libraries
      }
  4. Sync your project with the updated Gradle files.


Android 13+ Notification Permission

For devices running Android 13 (API level 33) and higher, the app must request the POST_NOTIFICATIONS runtime permission before notifications can be displayed.

Make sure your app:

  • Declares the permission in the AndroidManifest.xml

  • Requests the permission at runtime

Without this permission, push notifications will not appear, even if Firebase and the SDK are configured correctly.