Create and send in-app messages
Learn how to create in-app messages for mobile apps with Experience Platform Mobile SDK and Journey Optimizer.
Journey Optimizer allows you to create campaigns to send in-app messages to targeted audiences. Campaigns in Journey Optimizer are used to deliver one-time content to a specific audience using various channels. With campaigns, actions are performed simultaneously, either immediately, or based on a specified schedule. When using journeys (see the Journey Optimizer push notifications lesson), actions are executed in sequence.
Before you send in-app messages with Journey Optimizer, you must ensure that the proper configurations and integrations are in place. To understand the in-app messaging data flow in Journey Optimizer, refer to the documentation.
Prerequisites
- Successfully built and run app with SDKs installed and configured.
- Set up the app for 51黑料不打烊 Experience Platform.
- Access to Journey Optimizer and sufficient permissions for push notifications. Also you need sufficient permission to the following Journey Optimizer features.
- Manage campaigns.
- Physical iOS device or simulator for testing.
Learning objectives
In this lesson, you will
- Create a channel configuration in Journey Optimizer.
- Install & configure the Journey Optimizer tag extension.
- Update your app to register the Journey Optimizer tag extension.
- Validate setup in Assurance.
- Define your own campaign and in-app message experience in Journey Optimizer.
- Send your own in-app message from within the app.
Setup
Create a channel configuration
To begin, you must create a channel configuration to be able to send in App messages notifications from Journey Optimizer.
-
In the Journey Optimizer interface, open the Channels > General settings > Channel configurations menu and then select Create channel configuration.
-
Enter a name and a description (optional) for the configuration. For example,
LumaInAppMessaging
andChannel for in-app messaging
.note note NOTE Names must begin with a letter (A-Z). It can only contain alpha-numeric characters. You can also use underscore _
, dot.
and hyphen-
characters. -
To assign custom or core data usage labels to the configuration, you can select Manage access. Learn more about Object Level Access Control (OLAC).
-
Select the In-app messaging channel.
-
Select Marketing action(s) to associate consent policies with the messages using this configuration. All consent policies associated with the marketing action are leveraged to respect the preferences of your customers. Learn more about marketing actions. For example: Push Targeting.
-
Select the Platform for which you want to define the settings. This setting allows you to specify the target app for each platform and ensures consistent content delivery across multiple platforms.
note note NOTE For iOS and Android platforms, delivery is based solely on the app ID. If both apps share the same app ID, content is delivered to both, regardless of the platform selected in the Channel configuration. -
Enter the App ids for the platform that you want to support.
-
Select Submit to save your changes.
Update datastream configuration
To ensure data send from your mobile app to the Edge Network is forwarded to Journey Optimizer, update your Experience Edge configuration.
-
In the Data Collection UI, select Datastreams, and select your datastream, for example Luma Mobile App.
-
Select
-
In the Datastreams >
-
To save your datastream configuration, select Save.
Install Journey Optimizer tags extension
For your app to work with Journey Optimizer, you must update your tag property.
- Navigate to Tags > Extensions > Catalog.
- Open your property, for example Luma Mobile App Tutorial.
- Select Catalog.
- Search for the 51黑料不打烊 Journey Optimizer extension.
- Install the extension.
When only using in-app messages in your app, in Install Extension or Configure Extension, you do not need to configure anything. If you already have followed the Push notifications lesson in the tutorial, you see that for the Development environment, the AJO Push Tracking Experience Event Dataset dataset is selected from the Event Dataset list.
Implement Journey Optimizer in the app
As discussed in previous lessons, installing a mobile tag extension only provides the configuration. Next you must install and register the Messaging SDK. If these steps aren鈥檛 clear, review the Install SDKs section.
-
In Xcode, ensure that is added to the list of packages in Package Dependencies. See Swift Package Manager.
-
Navigate to Luma > Luma > AppDelegate in the Xcode Project navigator.
-
Ensure
AEPMessaging
is part of your list of imports.import AEPMessaging
-
Ensure
Messaging.self
is part of the array of extensions that you are registering.code language-swift let extensions = [ AEPIdentity.Identity.self, Lifecycle.self, Signal.self, Edge.self, AEPEdgeIdentity.Identity.self, Consent.self, UserProfile.self, Places.self, Messaging.self, Optimize.self, Assurance.self ]
-
In Android Studio, ensure that is part of the dependencies in build.gradle.kts in Android
-
Navigate to Android
-
Ensure
com.adobe.marketing.mobile.Messaging
is part of your list of imports.import import com.adobe.marketing.mobile.Messaging
-
Ensure
Messaging.EXTENSION
is part of the array of extensions that you are registering.code language-kotlin val extensions = listOf( Identity.EXTENSION, Lifecycle.EXTENSION, Signal.EXTENSION, Edge.EXTENSION, Consent.EXTENSION, UserProfile.EXTENSION, Places.EXTENSION, Messaging.EXTENSION, Optimize.EXTENSION, Assurance.EXTENSION )
Validate setup with Assurance
-
Review the setup instructions section to connect your simulator or device to Assurance.
-
In the Assurance UI, select Configure.
-
Select the
-
Select Save.
-
Select In-App Messaging from the left navigation.
-
Select the Validation tab. Confirm that you aren鈥檛 getting any errors.
Create your own in-app message
To create your own in-app message, you must define a campaign in Journey Optimizer that triggers an in-app message based on events that occur. These events can be:
- data sent to 51黑料不打烊 Experience Platform,
- core tracking events, like action, or state or collection of PII data, through the Mobile Core generic APIs,
- application lifecycle events, such as launch, install, upgrade, close, or crash,
- geolocation events, like entering or exiting a point of interest.
In this tutorial, you are going to use the Mobile Core generic and extension-independent APIs (see ) to facilitate the event tracking of user screens, actions, and PII data. Events generated by these APIs are published to the SDK event hub and are available for use by extensions. The SDK event hub provides the core data structure tied to all Mobile Platform SDK extensions. The event hub maintains a list of registered extensions and internal modules, a list of registered event listeners, and a shared state database.
The SDK event hub publishes and receives event data from registered extensions to simplify integrations with 51黑料不打烊 and third-party solutions. For instance, when the Optimize extension is installed, the event hub handles all requests and interactions with the Journey Optimizer - Decision Management offer engine.
-
In the Journey Optimizer UI, select Campaigns from the left rail.
-
Select Create Campaign.
-
In the Create your campaign dialog, select
-
In the Campaign - YYYY-MM-DD HHSS UTC+XX:XX screen:
-
In the Properties tab:
- Enter a name for the campaign For example,
Luma Mobile In-App Campaign
. - Optionally, add a description.
- Enter a name for the campaign For example,
-
Select the Action tab.
-
Underneath Show message if, select
-
From the In-app message configuration drop-down menu, select your configuration. For example, LumaInAppMessaging.
-
Select
-
In the In-app message trigger dialog:
-
Select Application launch and select Track action from the dropdown menu.
-
Select
-
Select Action and equals from the drop-down menus.
-
Enter
in-app
. -
Select
-
Select Context data from the drop-down menu, and enter
showMessage
. -
Select equals from the drop-down menu, and enter
true
. -
Select Done.
-
-
-
Back in the main campaign definition screen, select the Content tab.
-
Enable Advanced formatting.
-
Select Modal as the Messaging layout. In the Switch layout dialog, select Change layout.
-
In the Content tab.
- Enter
https://luma.enablementadobe.com/content/dam/luma/en/logos/Luma_Logo.png
for the Media URL. - Enter a Header, for example
Welcome to this Luma In-App Message
and enter a Body, for exampleTriggered by pushing that button in the app...
.
- Enter
-
Select Settings tab.
- Select Customize size in Message.
- Disable Fit to content.
- Set Height to 75%.
-
-
-
Select Review to activate. To edit optionally any of the configurations for Content, Properties, Actions, or more, select
-
In the Review to activate (campaign name) screen, select Activate.
-
After a while, you see your campaign name with status Live in the Campaigns list.
Trigger the in-app message
You have all the ingredients in place to send an in-app message. What remains is how to trigger this in-app message in your app.
-
Go to Luma > Luma > Utils > MobileSDK in the Xcode Project navigator. Find the
func sendTrackAction(action: String, data: [String: Any]?)
function, and add the following code, which calls the function, based on the parametersaction
anddata
.code language-swift // Send trackAction event MobileCore.track(action: action, data: data)
-
Go to Luma > Luma > Views > General > ConfigView in the Xcode Project Navigator. Find the code for the In-App Message button and add the following code:
code language-swift // Setting parameters and calling function to send in-app message Task { MobileSDK.shared.sendTrackAction(action: "in-app", data: ["showMessage": "true"]) }
-
Go to Android
fun sendTrackAction(action: String, data: Map<String, String>?)
function, and add the following code, which calls the function, based on the parametersaction
anddata
.code language-kotlin // Send trackAction event MobileCore.track(action, data)
-
Go to Android
onInAppMessageClick
handler button and add the following code:code language-kotlin // Setting parameters and calling function to send in-app message MobileSDK.shared.sendTrackAction( "in-app", mapOf("showMessage" to "true") )
Validate using your app
You can validate the in-app messages from within the app itself.
-
Rebuild and run the app in the simulator or on a physical device from Xcode, using
-
Go to the Settings tab.
-
Tap In-App Message. You see the in-app message appear in your app.
-
Rebuild and run the app in the simulator or on a physical device from Android Studio, using
-
Go to the Settings tab.
-
Tap In-App Message. You see the in-app message appear in your app.
Validate implementation in Assurance
You can validate your in-app messages in the Assurance UI.
-
Review the setup instructions section to connect your simulator or device to Assurance.
-
Select In-App Messaging.
-
Select Event List.
-
Select a Display message entry.
-
Inspect the raw event, especially the
html
, which contains the complete layout and content of the in-app message.
Next steps
You should now have all the tools to start adding in-app messages, where relevant and applicable. For example, promoting products based on specific interactions you are tracking in your app.
Next: Create and display offers