Check out what’s new from Firebase@ Google I/O 2021, and join our alpha program for early access to the new Remote Config personalization feature. Learn more

Get started with Firebase In-App Messaging

This quickstart shows you how to set up Firebase In-App Messaging and send your first message.

Before you begin

If you haven't already, add Firebase to your Android project.

Add the Firebase In-App Messaging SDK to your project

Using the Firebase Android BoM, declare the dependency for the In-App Messaging Android library in your module (app-level) Gradle file (usually app/build.gradle).

To use In-App Messaging, you must enable Google Analytics in your Firebase project and add the Firebase SDK for Google Analytics to your app.

Java

dependencies {
    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:28.1.0')

    // Declare the dependencies for the In-App Messaging and Analytics libraries
    // When using the BoM, you don't specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-inappmessaging-display'
    implementation 'com.google.firebase:firebase-analytics'
}

By using the Firebase Android BoM, your app will always use compatible versions of the Firebase Android libraries.

(Alternative) Declare Firebase library dependencies without using the BoM

If you choose not to use the Firebase BoM, you must specify each Firebase library version in its dependency line.

Note that if you use multiple Firebase libraries in your app, we highly recommend using the BoM to manage library versions, which ensures that all versions are compatible.

dependencies {
    // Declare the dependencies for the In-App Messaging and Analytics libraries
    // When NOT using the BoM, you must specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-inappmessaging-display:20.0.0'
    implementation 'com.google.firebase:firebase-analytics:19.0.0'
}

Kotlin+KTX

dependencies {
    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:28.1.0')

    // Declare the dependencies for the In-App Messaging and Analytics libraries
    // When using the BoM, you don't specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-inappmessaging-display-ktx'
    implementation 'com.google.firebase:firebase-analytics-ktx'
}

By using the Firebase Android BoM, your app will always use compatible versions of the Firebase Android libraries.

(Alternative) Declare Firebase library dependencies without using the BoM

If you choose not to use the Firebase BoM, you must specify each Firebase library version in its dependency line.

Note that if you use multiple Firebase libraries in your app, we highly recommend using the BoM to manage library versions, which ensures that all versions are compatible.

dependencies {
    // Declare the dependencies for the In-App Messaging and Analytics libraries
    // When NOT using the BoM, you must specify versions in Firebase library dependencies
    implementation 'com.google.firebase:firebase-inappmessaging-display-ktx:20.0.0'
    implementation 'com.google.firebase:firebase-analytics-ktx:19.0.0'
}

Send a test message

Get your app's installation ID

To conserve power, Firebase In-App Messaging only retrieves messages from the server once per day. That can make testing difficult, so the Firebase console allows you to specify a test device that displays messages on demand.

That testing device is determined by a FirebaseInstallations ID, or FID. Find your testing app's FID by checking the Logcat in Android Studio for the following `Info` level log:

I/FIAM.Headless: Starting InAppMessaging runtime with Installation ID YOUR_INSTALLATION_ID

Send a message to your testing device

Once you've launched your app on the testing device and you have its Firebase installation ID (FID), you can try out your Firebase In-App Messaging setup by sending a test message:

  1. In the Firebase console, open In-App Messaging.
  2. Click New Campaign.
  3. Enter a Title for your first message.
  4. Click Test on your Device
  5. Enter your app's Firebase installation ID in the Add an installation ID field.
  6. Click Test to send the message.

Firebase In-App Messaging sends your test message as soon as you click Test. To see the message, you need to close, then reopen the app on your testing device.

To confirm whether your device is a test device, look for the following log message:

I/FIAM.Headless: Setting this device as a test device