BrazeInAppMessageManager

This class is used to display in-app messages that are either sent from Braze or are created natively in the host app. It will only show one in-app message at a time and will place all other in-app messages onto a stack. The BrazeInAppMessageManager will also keep track of in-app impressions and clicks, which can be viewed on the dashboard.

If there is already an in-app message being displayed, the new in-app message will be put onto the top of the stack and can be displayed at a later time. If there is no in-app message being displayed, then the IInAppMessageManagerListener.beforeInAppMessageDisplayed will be called. The InAppMessageOperation return value can be used to control when the in-app message should be displayed. A suggested usage of this method would be to delay in-app message messages in certain parts of the app by returning InAppMessageOperation.DISPLAY_LATER when in-app message would be distracting to the users app experience. If the method returns InAppMessageOperation.DISPLAY_NOW then the in-app message will be displayed immediately.

The IInAppMessageManagerListener.onInAppMessageClicked and IInAppMessageManagerListener.onInAppMessageDismissed methods can be used to override the default click and dismiss behavior.

By default, in-app messages fade in and out from view. The slideup type of in-app message slides in and out of view can be dismissed by swiping the view horizontally. If the in-app message's DismissType is set to AUTO_DISMISS, then the in-app message will animate out of view once the set duration time has elapsed.

In order to use a custom view, you must create a custom view factory using the BrazeInAppMessageManager.setCustomInAppMessageViewFactory method.

A new in-app message android.view.View object is created when a in-app message is displayed and also when the user navigates away to another android.app.Activity. This happens so that the Activity can be garbage collected and does not create a memory leak. For that reason, the BrazeInAppMessageManager.registerInAppMessageManager and BrazeInAppMessageManager.unregisterInAppMessageManager must be called in the Activity.onResume() and Activity.onPause() methods of every Activity.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open val activity: Activity?
Link copied to clipboard
Link copied to clipboard

An In-App Message being carried over during the unregisterInAppMessageManager transition.

Link copied to clipboard
Link copied to clipboard

The stack of In-App Messages waiting to be displayed.

Link copied to clipboard
Link copied to clipboard

Gets whether an in-app message is currently displaying on the device.

Link copied to clipboard

Determines whether the next call to BrazeInAppMessageManager.unregisterInAppMessageManager will be ignored.

Link copied to clipboard

An In-App Message that could not display after a call to requestDisplayInAppMessage due to no Activity being registered via registerInAppMessageManager.

Functions

Link copied to clipboard
open fun addInAppMessage(inAppMessage: IInAppMessage?)

Provides a in-app message that will then be handled by the in-app message manager. If no in-app message is being displayed, it will attempt to display the in-app message immediately.

Link copied to clipboard
open fun displayInAppMessage(inAppMessage: IInAppMessage, isCarryOver: Boolean)

Internal method, do not call as part of an integration!

Link copied to clipboard

Ensures the InAppMessageManager is subscribed in-app message events if not already subscribed. Before this method gets called, the InAppMessageManager is not subscribed to in-app message events and cannot display them. Every call to registerInAppMessageManager() calls this method.

Link copied to clipboard

Hides any currently displaying in-app message. Note that in-app message animation is configurable on the in-app message model itself and should be configured there.

Link copied to clipboard

Determines whether the in-app message was triggered for the same user as the current user.

Link copied to clipboard

Registers the in-app message manager, which will listen to and display incoming in-app messages. The current Activity is required in order to properly inflate and display the in-app message view.

Link copied to clipboard

Asks the InAppMessageManager to display the next in-app message if one is not currently being displayed. If one is being displayed, this method will return false and will not display the next in-app message.

Link copied to clipboard

Resets the BrazeInAppMessageManager to its original state before the last in-app message was displayed. This allows for a new in-app message to be displayed after calling this method. ViewUtils.setActivityRequestedOrientation is called with the original orientation before the last in-app message was displayed.

Link copied to clipboard
open fun setBackButtonDismissesInAppMessageView(backButtonDismissesInAppMessageView: Boolean)

Sets whether the hardware back button dismisses in-app messages. Defaults to true. Note that the hardware back button default behavior will be used instead (i.e. the host Activity's Activity.onKeyDown method will be called).

Sets whether the tapping outside the modal in-app message content dismiss the message. Defaults to false.

Assigns a custom IInAppMessageManagerListener that will be used when displaying control in-app messages. To revert back to the default IInAppMessageManagerListener, call this method with null.

Link copied to clipboard

Assigns a custom IHtmlInAppMessageActionListener that will be used during the display of Html in-app messages.

Link copied to clipboard

Assigns a custom IInAppMessageAnimationFactory that will be used to animate the in-app message View. To revert back to the default IInAppMessageAnimationFactory, call the setCustomInAppMessageAnimationFactory method with null.

Link copied to clipboard

Assigns a custom IInAppMessageManagerListener that will be used when displaying in-app messages. To revert back to the default IInAppMessageManagerListener, call this method with null.

Link copied to clipboard

Assigns a custom IInAppMessageViewFactory that will be used to create the in-app message View. To revert back to the default IInAppMessageViewFactory, call the setCustomInAppMessageViewFactory method with null.

Link copied to clipboard

Sets a custom IInAppMessageViewWrapperFactory that will be used to display an IInAppMessage to the user.

Link copied to clipboard

Unregisters the in-app message manager.

Link copied to clipboard

For in-app messages that have a preferred orientation, locks the screen orientation and returns true if the screen is currently in the preferred orientation. If the screen is not currently in the preferred orientation, returns false.