Message
The Message
class contains the definition of an in-app message and controls its tracking via Experience Edge events.
iOS Interface - Message
Message
objects are only created by the AEPMessaging extension, and passed as the message
parameter in MessagingDelegate
protocol methods.
Public variables
id
Identifier of the Message
. This value matches the Message Execution ID assigned by Adobe Journey Optimizer (AJO) Campaign.
Copied to your clipboardpublic var id: String
autoTrack
If set to true
(default), Experience Edge events will automatically be generated when this Message
is triggered, displayed, and dismissed.
Copied to your clipboardpublic var autoTrack: Bool = true
view
Holds a reference to the message's WKWebView
(iOS) or WebView
(Android) instance, if it exists.
Copied to your clipboardpublic var view: UIView? {fullscreenMessage?.webView}
Public functions
show
Signals to the UIService (in AEPServices
) that the message should be shown.
If autoTrack
is true, calling this method will result in an decisioning.propositionTrigger
Edge Event being dispatched.
Copied to your clipboardpublic func show()
dismiss(suppressAutoTrack:)
Signals to the UIService that the message should be removed from the UI.
If autoTrack
is true, calling this method will result in an decisioning.propositionDismiss
Edge Event being dispatched.
track(_:withEdgeEventType:)
Generates and dispatches an Edge Event for the provided interaction
and eventType
.
iOS
Swift
Copied to your clipboardpublic func track(_ interaction: String?, withEdgeEventType eventType: MessagingEdgeEventType)
Parameters
- interaction: A custom
String
value to be recorded in the interaction - eventType: The
MessagingEdgeEventType
to be used for the ensuing Edge Event
Swift
Copied to your clipboardpublic func track(_ interaction: String?, withEdgeEventType eventType: MessagingEdgeEventType)
Parameters
- interaction: A custom
String
value to be recorded in the interaction - eventType: The
MessagingEdgeEventType
to be used for the ensuing Edge Event
handleJavascriptMessage(_:withHandler:)
Adds a handler for named JavaScript messages sent from the message's WKWebView
.
The parameter passed to handler
will contain the body of the message passed from the WKWebView
's JavaScript.
For a full guide on how to use handleJavascriptMessage
, read Call native code from the Javascript of an in-app message.
iOS
Swift
Copied to your clipboardpublic func handleJavascriptMessage(_ name: String, withHandler handler: @escaping (Any?) -> Void)
Parameters
- name: The name of the message that should be handled by
handler
- handler: The method or closure to be called with the body of the message created in the Message's JavaScript
Swift
Copied to your clipboardpublic func handleJavascriptMessage(_ name: String, withHandler handler: @escaping (Any?) -> Void)
Parameters
- name: The name of the message that should be handled by
handler
- handler: The method or closure to be called with the body of the message created in the Message's JavaScript
Android Interface - Message
The Message
class has the business logic related to the in-app message to perform actions like sending tracking events on interactions and suppress tracking. If your app implements PresentationDelegate
, it will receive a Presentable
object, which is the Mobile Core class containing in-app message view. You will need to get the Message
object associated with Presentable
object using the MessagingUtils.getMessageForPresentable(Presentable)
API. Refer to this tutorial for more details.
Public functions
show
Signals to the UIService that the message should be shown.
If autoTrack
is true, calling this method will result in an "decisioning.propositionDisplay" Edge Event being dispatched.
Copied to your clipboardvoid show()
dismiss
This API has been changed in v3.0.0 of Adobe Journey Optimizer extension.
In earlier versions, this API accepted a parameter suppressAutoTrack
: If set to true
, the decisioning.propositionDismiss
Edge Event will not be sent regardless of the autoTrack
setting.
Signals to the UIService that the message should be removed from the UI.
If autoTrack
is true, calling this method will result in an "decisioning.propositionDismiss" Edge Event being dispatched.
track
Generates and dispatches an Edge Event for the provided interaction
and eventType
.
Android
Java
Copied to your clipboardvoid track(final String interaction, final MessagingEdgeEventType eventType)
Parameters
- interaction: A custom
String
value to be recorded in the interaction - eventType: The
MessagingEdgeEventType
to be used for the ensuing Edge Event
Java
Copied to your clipboardvoid track(final String interaction, final MessagingEdgeEventType eventType)
Parameters
- interaction: A custom
String
value to be recorded in the interaction - eventType: The
MessagingEdgeEventType
to be used for the ensuing Edge Event
setAutoTrack
Sets the Message
's auto tracking preference.
getAutoTrack
Returns the Message
's auto tracking preference.
evaluateJavascript
This API has been removed in v3.0.0 of Adobe Journey Optimizer extension.
Migrate to use PresentationDelegate
and use the InAppMessageEventHandler.evaluateJavascript(String, AdobeCallback)
API instead. Refer to this tutorial for more details.
Evaluates the passed in String
content containing JavaScript code using the Message
's webview. handleJavascriptMessage
must be called with a valid callback before calling evaluateJavascript
as the body of the message passed from the JavaScript code execution will be returned in the AdobeCallback
.
For a full guide on how to use handleJavascriptMessage
, read the guide on executing JavaScript methods from native code.
handleJavascriptMessage
This API has been removed in v3.0.0 of Adobe Journey Optimizer extension.
Migrate to use PresentationDelegate
and use the InAppMessageEventHandler.handleJavascriptMessage(String, AdobeCallback)
API instead. Refer to this tutorial for more details.
Adds a handler for named JavaScript messages sent from the message's WebView
.
The AdobeCallback
will contain the body of the message passed from the WebView
's JavaScript.
For a full guide on how to use handleJavascriptMessage
, read the guide on calling native code from the Javascript of an in-app message.
Android
getId
Returns the message's id.
Copied to your clipboardString getId()
getParent
This API has been removed in v3.0.0 of Adobe Journey Optimizer extension.
Please use the MessagingUtils.getMessageForPresentable(Presentable)
API instead. Refer to this tutorial for more details.
Returns the Object
which created this Message
.
Copied to your clipboardObject getParent()
getWebView
This API has been removed in v3.0.0 of Adobe Journey Optimizer extension.
Functionality is no longer supported.
Returns a reference to the message's WebView
instance, if it exists.
Copied to your clipboardWebView getWebView()