In-app messages
UpdatedIncorporate in-app messages to send dynamic, personalized content to people using your app. With in-app messages, you can speak directly to your app’s users when they use your app.
How it works
An in-app message is a message that people see within the app. To set up in app messaging, install and initialize the tracking
and messaging-in-app
packages.
People won’t see your in-app messages until they open your app. If you set an expiry period for your message, and that time elapses before someone opens your app, they won’t see your message.
You can also set page rules to display your in-app messages when people visit specific pages in your app. However, to take advantage of page rules, you need to implement screen tracking features. Screen tracking tells us the names of your pages and which page a person is on, so we can display in-app messages on the correct pages in your app.
in-app message]-->d{is the app open?} d-->|yes|f[user gets message] d-->|no|e[hold message
until app opens] e-->g{did the message
expire?} g-->|no, wait for user
to open the app|d g-->|yes|h[user doesn't
get the message]
Install the SDK and in-app module
Make sure that you add update your repositories in the
settings.gradle
file to include the in-app SDK.dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() // only needed for in-app messaging in SDK versions below 3.6.1 // maven { url 'https://maven.gist.build' } } }
Implement the
messaging-in-app
package.implementation "io.customer.android:messaging-in-app:4.3.0"
Initialize the SDK with the in-app module
Simply initialize the SDK with the MessagingInApp
module and your app will be able to receive in-app messages. Create a campaign and send your first in-app message to test your implementation!
CustomerIOBuilder(
siteId = "siteId",
apiKey = "apiKey",
appContext = application,
).apply {
// Setup In-app messaging
addCustomerIOModule(ModuleMessagingPushFCM())
addCustomerIOModule(ModuleMessagingInApp())
logLevel(CiologLevel.DEBUG)
// For fragment-based apps or Jetpack Compose, disable this and use manual screen tracking
autoTrackActivityScreens(true)
region(Region.US)
build()
}
// `ModuleMessagingInApp` takes in optional configuration options.
// One option is an event listener to get notified when a message is shown, dismissed, or an action is taken.
ModuleMessagingInApp(config = MessagingInAppModuleConfig.Builder()
.setEventListener(object : InAppEventListener {
override fun errorWithMessage(message: InAppMessage) {}
override fun messageActionTaken(message: InAppMessage, actionValue: String, actionName: String) {}
override fun messageDismissed(message: InAppMessage) {}
override fun messageShown(message: InAppMessage) {}
})
.build()
)
Page rules
You can set page rules when you create an in-app message. A page rule determines the page that your audience must visit in your app to see your message. However, before you can take advantage of page rules, you need to:
- Enable screen tracking in the SDK. If you are using a view(xml)-based() UI with activities, you can enable automatic screen tracking by calling
autoTrackActivityScreens(true)
during SDK initialization. However, if your app is fragment-based or utilizes Jetpack Compose, we recommend utilizing manual screen tracking with thescreen
method. - Provide page names to whomever sets up in-app messages in fly.customer.io.
The SDK automatically uses label in your manifest file as the page/screen name. If your screens don’t have labels, you won’t be able to set up page rules and screenview events will have an empty event name
.
You should inform anybody creating in-app messages about page names if you want to set up page rules, to make sure that your messages appear on the right pages of your app. If we don’t recognize the page that you set for a page rule, your audience will never see your message.
Keep in mind: page rules are case sensitive. If you’re targeting your mobile app, make sure your page rules match the casing of the name
in your screen
events. If you’re targeting your website, your page rules should always be lowercase.