Exploring Firebase In-App Messaging

This week, Firebase added a new product to their ecosystem: In-App Messaging.

Firebase is aiming to make it easier for developers to engage their active users within their apps and guide the users in the right direction to take valuable actions. Use cases for In-App Messaging include prompting users to share the app, purchase an in-app item, etc.

It requires very little developer skill and enables anyone with any background to send customized in-app messages to specific user groups at a scheduled time period and provides insights on the campaign performance.

Implementation

In order to implement In-App Messaging in our app, we need to add the dependency to your build.gradle:

implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.1'

That’s it! This is all we need to do to start using Firebase In-App Messaging. Just make sure you’ve added Firebase to your project (google-services plugin, google-services.json, etc.).

Sending In-App Messages Through the Firebase Console

Now we can send in-app messages to our users. Let’s open the In-App Messaging section in the Firebase console and select New campaign to send our first in-app message.

It takes only 4 steps to configure and start a campaign.

Styling

The first step is to add the content and set the message style for our campaign. Before editing the content, we should decide what kind of layout we want to send: modal (dialog style), image only or top banner.

1. Modal

The message title, background and text colors are the required info for the modal type message. Optionally, we can add a body for details and an image for a better visual and a button to let user take an action. We can use deep linking (or better yet, Firebase Dynamic Links) to send the user to a specific content or just set a URL to be opened in a browser.

While the device preview on the right side of the configuration page is pretty handy, it’s always better to try the result in our actual app on the specific devices we prefer (to see how the result changes based on the dimensions and density). For this, we can click on Test on your device.

To get our device’s instance ID, we need to run our app (after adding the In-App Messaging dependency) on the device we want to test the message on. When the app runs, in the Logcat we can see the following output:

I/FIAM.Headless: Starting InAppMessaging runtime with Instance ID INSTANCE_ID

All we need to do is to copy the ID from the end of the line and add it to the Firebase console. After clicking on the Test button, we need to close the app and open it again to see the message.

2. Image Only

The image only option just requires an image URL. Optionally, we can add a URL which will make the whole message clickable.

3. Top banner

Top banner is similar to the modal option in terms of configuration with the only difference being that we don’t need a button for the top banner as the banner itself becomes clickable as soon as we add an action URL.

Targeting

Once we’re satisfied with the styling, we can pick our target audience for the campaign. We should choose a clear name (and ideally, a description) for the campaign so in the future we can easily come back to any campaign we ran in the past, see the results and repeat it if we want to.

Audience feature of Google Analytics for Firebase plays a great role here. Assuming that we’re using Google Analytics for Firebase (and we should if we want to get the most out of In-App Messaging), we can create audiences based on the user properties (such as age range, country, device info, etc.) and the actions users take in the app (opening the app, viewing a screen, clicking on a button, etc.). Then we can use these audiences here for targeting specific user groups.

Scheduling

After picking our target audience, we need to set the time range for the campaign. We can choose to start it now or at a future date. We also have the option to finish it at some point or keep it available until we manually stop the campaign.

Since In-App Messages are shown to the user while they’re using the app, we can chose an analytics event as a trigger to display the message.

We can also choose to show the message to a user only once during a campaign or set an interval in which the message can be displayed.

Tagging Impressions as Conversion Events

Optionally, it’s possible to tag the message impressions as conversion events.

Publishing

Finally, it’s time to publish our campaign. If we’re not done with configuring the campaign or still need to decide on the strategy, we can always save it as a draft and come back later to modify.

Once we’re satisfied with everything, we can publish our campaign.

After Publishing

We can now sit back and monitor the performance of the campaign on the same page.

I’m aware that my campaign is not performing well 😳 I’ll update the image once my impressions take effect.

Additionally, if we like the performance of the campaign or think that we need a similar campaign with a slightly different configuration, we can easily duplicate an existing campaign.

Unless I’m missing something, there’s a compatibility issue between In-App Messaging and Cloud Firestore 🤦‍ When I tried to run the app with both dependencies included, I got the following error:

Program type already present: com.google.a.a.a.a.zza

There are already related questions on Stack Overflow, and I’m also looking for a fix. I’m sure the Firebase team will fix it soon but if I’ll find a workaround, I’ll add it here.

Update: Abe Haskins from the Firebase team has forwarded the issue to the team last week:

And it has already been fixed. The team is on fire 🔥 Make sure you’re using the version17.0.1 or above. Thanks Pablo A. Martínez for the ping.

If you think there’s a mistake or that I skipped something, simply reach out to me and I’ll be happy to update the article. If you find this helpful, please click 👏 and share to make it easier for others to find it.

Android developer @ MyDrive Solutions. GDG London lead. Technology admirer. International speaker. World traveler.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store