In-app messages for MAUI SDK
Show native in-app messages in your MAUI app with the Bloomreach MAUI SDK. Track message events, customize click and close actions, and fix display issues.
Use the SDK to display native in-app messages in your app based on definitions set up in Marketing.
In-app messages work out of the box once the SDK is installed and configured in your app. No development work is required. You can customize the behavior to meet your specific requirements.
NoteTo create in-app messages in the Marketing web app, see the In-app messages user guide.
Also see In-app messages FAQ at Bloomreach Support Help Center.
Tracking
The SDK automatically tracks banner events for in-app messages with the following values for the action event property:
show: In-app message displayed to user.click: User clicked on action button inside in-app message. The event also contains the correspondingtextandlinkproperties.close: User clicked on close button inside in-app message.error: Displaying in-app message failed. The event contains anerrorproperty with an error message.
ImportantThe tracking consent feature may affect in-app message tracking. When enabled, it requires explicit consent for tracking. For details, see the tracking consent documentation.
Customization
Customize in-app message actions
You can react to in-app message events and override the SDK's default behavior by passing an InAppMessageCallback to Bloomreach.BloomreachSDK.SetInAppMessageCallback. Override the methods you need:
InAppMessageShown: the message was displayed.InAppMessageClickAction: the user clicked a button.buttoncontains its text and URL.InAppMessageCloseAction: the message was closed.interactionistruewhen the user closed the message.interactionisfalsewhen the message closed by itself, for example, after a timeout.buttoncontains the close button, if the message has one.
InAppMessageError: displaying the message failed.
If overrideDefaultBehavior is true, the SDK doesn't perform the default in-app action (for example, resolving a deep link).
If trackActions is false, the SDK doesn't track click and close in-app message events automatically.
We recommend setting up the callback as early as possible, ideally right after Configure. Callback methods may run on a background thread.
using Bloomreach;
public class MyInAppMessageCallback : InAppMessageCallback
{
// overrideDefaultBehavior: true - the SDK does not open links itself
// trackActions: false - the SDK does not track click and close events
public MyInAppMessageCallback() : base(overrideDefaultBehavior: true, trackActions: false) { }
public override void InAppMessageShown(InAppMessage message)
{
// message is now visible
}
public override void InAppMessageClickAction(InAppMessage message, InAppMessageButton button)
{
Bloomreach.BloomreachSDK.TrackInAppMessageClick(message, button.Text, button.Url);
// open button.Url in your app
}
public override void InAppMessageCloseAction(InAppMessage message, InAppMessageButton? button, bool interaction)
{
Bloomreach.BloomreachSDK.TrackInAppMessageClose(message, interaction, button?.Text);
}
public override void InAppMessageError(InAppMessage? message, string errorMessage)
{
// log the error
}
}
Bloomreach.BloomreachSDK.SetInAppMessageCallback(new MyInAppMessageCallback());To restore the SDK's default behavior, call Bloomreach.BloomreachSDK.RemoveInAppMessageCallback().
If you set trackActions to false but still want to track click or close events under some circumstances, call TrackInAppMessageClick or TrackInAppMessageClose from the callback.
Important
SetInAppMessageActionCallback(overrideDefaultBehavior, trackActions, listener)from SDK 1.x still works but is deprecated. It only reports clicks and closes.
The method TrackInAppMessageClose tracks a close event. Without the optional parameter isUserInteraction, the event's interaction value depends on the platform:
- Android:
true. - iOS:
false.
Pass isUserInteraction to track the same value on both platforms, and buttonText to record which close button was used.
ImportantThe tracking consent feature may affect
TrackInAppMessageClickandTrackInAppMessageClose. When enabled, it requires explicit consent for tracking. For details, see the tracking consent documentation.
Troubleshooting
Use these pointers to troubleshoot in-app message issues.
Set Verbose Log LevelThe SDK logs a lot of information at
Verboselevel while loading in-app messages. When troubleshooting in-app message issues, make sure to set the SDK's log level at least toVerbose.
In-app message not displayed
To troubleshoot why an in-app message didn't display on your device, first make sure the message was preloaded to the device. Then troubleshoot message display.
Troubleshoot in-app message preloading issues
- The SDK requests in-app messages from the Marketing platform any time one of the following occurs:
Bloomreach.BloomreachSDK.IdentifyCustomeris called.Bloomreach.BloomreachSDK.Anonymizeis called.- Any event (except push notification clicked or opened, or session ends) is tracked and the in-app messages cache is older than 30 minutes.
- The SDK should subsequently receive a response from the Marketing platform containing all available in-app messages targeted at the current customer. The SDK preloads these messages in a local cache.
- The SDK caches in-app messages. When you create or modify an in-app message in Marketing, the changes typically reach the SDK after 30 minutes. To reflect changes immediately, call
Bloomreach.BloomreachSDK.IdentifyCustomerorBloomreach.BloomreachSDK.Anonymizeto trigger reloading. - Analyze the log messages to determine whether the SDK requested and received in-app messages and preloaded your message.
- If the SDK requested and received in-app messages but didn't preload your message, check these causes:
- The local cache may be outdated. Wait for or trigger the next preload.
- The current customer may not match the audience targeted by the in-app message. Verify the message's audience in Marketing.
ImportantInvoking
Bloomreach.BloomreachSDK.Anonymizetriggers fetching in-app messages immediately.Bloomreach.BloomreachSDK.IdentifyCustomermust first be flushed to the backend successfully, because the backend must know the customer to assign in-app messages with a matching audience. If you set flush mode to anything other thanFlushMode.Immediate, callawait Bloomreach.BloomreachSDK.FlushData(). This finalizes theIdentifyCustomerprocess and triggers an in-app messages fetch.
Troubleshoot in-app message display issues
If your app is successfully requesting and receiving in-app messages but they're not displayed, consider the following causes.
-
In-app messages are triggered when an event is tracked, based on conditions set up in Marketing. Once a message passes those filters, the SDK tries to present the message.
-
The SDK hooks into the app lifecycle.
- On iOS, the SDK presents the message in the top-most
presentedViewController. Slide-in messages are an exception, because they useUIWindowdirectly. - On Android, the SDK presents the message in a new Activity. Slide-in messages are an exception, because the SDK injects them directly into the currently running Activity.
- On iOS, the SDK presents the message in the top-most
-
Your app may present another
UIViewController(iOS) or start a newActivity(Android) at the same time as the message. The message might then be displayed and immediately dismissed, because its parent leaves the screen. Keep this in mind if the logs show that your message was displayed but you don't see it. -
In-app messages configured to show on
App loadare displayed when asession_startevent is tracked.- If you close and quickly reopen the app, the session may not have timed out, so the message isn't displayed.
- If you use manual session tracking, the message isn't displayed unless you track a
session_startevent yourself.
-
An in-app message can only be displayed if it's loaded, including its images. If the message isn't fully loaded yet, the SDK registers a request-to-show for it. The SDK then displays the message once it's fully loaded. The request-to-show has a timeout of 3 seconds. In case of unpredicted behavior, such as image loading taking too long, the message may not be displayed directly.
-
If in-app message loading hits the timeout of 3 seconds, the SDK displays the message the next time its trigger event is tracked. For example, a
session_startevent triggers an in-app message, but loading that message times out. The SDK doesn't display the message directly. Once the message is loaded, the SDK displays it the next time asession_startevent is tracked. -
Image downloads are limited to 10 seconds per image. If an in-app message contains a large image that can't be downloaded within this limit, the message isn't displayed.
- For an HTML in-app message that contains multiple images, the limit applies per image.
- Failure of any image download prevents the HTML in-app message from being displayed.
In-app message shows incorrect image
To reduce the number of API calls and fetching time of in-app messages, the SDK caches the images contained in messages. Once the SDK downloads an image, an image with the same URL may not be downloaded again.
If a message contains a new image with the same URL as a previously used image, the SDK displays the previous image because it was already cached. For this reason, we recommend always using different URLs for different images.
In-app message actions not tracked
If you have set a custom InAppMessageCallback using Bloomreach.BloomreachSDK.SetInAppMessageCallback, the SDK only tracks actions automatically if trackActions is true. If trackActions is false, you must manually track the actions. For details, see Customize in-app message actions.
Log messages
The SDK logs the process of requesting, receiving, preloading, and displaying in-app messages at verbose log level. Use these logs to troubleshoot in-app message issues.
See the Android and iOS SDK documentation for the relevant log messages for each platform.
Updated 1 day ago

