12.4 Messaging

Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably send messages at no cost.

https://firebase.google.com/docs/cloud-messaging

In-app Messaging

Firebase In-App Messaging helps you engage your app's active users by sending them targeted, contextual messages that encourage them to use key app features. For example, you could send an in-app message to get users to subscribe, watch a video, complete a level, or buy an item. You can customize messages as cards, banners, modals, or images, and set up triggers so that they appear exactly when they'd benefit your users most.

To use In-App Messaging, you must first add it's SDK to your Android app (make sure your Firebase project is set up, the steps of which are covered in the first section 11.1 and that your analytics are set up, covered in 11.3!)

dependencies {
    // Import the BoM for the Firebase platform
    implementation platform('com.google.firebase:firebase-bom:27.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'
}

To create an In-app message campaign, visit https://console.firebase.google.com/project/_/inappmessaging/ where you can specify how your notification should look like, and who to target based on any created users from Audiences or specific event triggers from setting up your Analytics!

When creating a notification, you can test it by specifying something called the installation ID:

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

Last updated