Before you begin
If you haven't already, add Firebase to your Android project.
In your project-level
build.gradle file, make sure to include
Google's Maven repository in both your
Add the Firebase In-App Messaging SDK to your project
Add the dependency for the In-App Messaging Android library to your module (app-level) Gradle
For an optimal experience with In-App Messaging, we recommend enabling Google Analytics in your project. Also, as part of setting up Analytics, you need to add the Firebase SDK for Analytics to your app.
implementation 'com.google.firebase:firebase-inappmessaging-display:19.1.1' implementation 'com.google.firebase:firebase-analytics:17.5.0'
implementation 'com.google.firebase:firebase-inappmessaging-display-ktx:19.1.1' implementation 'com.google.firebase:firebase-analytics-ktx:17.5.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 Firebase In-App Messaging setup by sending a test message:
- In the Firebase console, open In-App Messaging.
- Once there, click New Campaign.
- Enter a Title for your first message.
- Click Test on your Device
- Enter your app's Firebase installation ID in the Add an installation ID field.
- Click Test to send the message.
Firebase In-App Messaging sends your test message as soon as you click Test. To see it, 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