The Message
class contains the definition of an in-app message and controls its tracking via Experience Edge events.
Message
objects are only created by the AEPMessaging extension, and passed as the message
parameter in MessagingDelegate
protocol methods.
Identifier of the Message
.
public var id: String
If set to true
(default), Experience Edge events will automatically be generated when this Message
is triggered, displayed, or dismissed.
public var autoTrack: Bool = true
Holds a reference to the message's WKWebView
instance, if it exists.
public var view: UIView? {
fullscreenMessage?.webView
}
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.
public func show()
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.
public func dismiss(suppressAutoTrack: Bool? = false)
- suppressAutoTrack - if set to
true
, the "decisioning.propositionDismiss" Edge Event will not be sent regardless of theautoTrack
setting.
Generates and dispatches an Edge Event for the provided interaction
and eventType
.
public func track(_ interaction: String?, withEdgeEventType eventType: MessagingEdgeEventType)
- interaction - a custom
String
value to be recorded in the interaction - eventType - the
MessagingEdgeEventType
to be used for the ensuing Edge Event
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.
public func handleJavascriptMessage(_ name: String, withHandler handler: @escaping (Any?) -> Void)
- 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 Message's Javascript
For more information on how to use handleJavascriptMessage
, read Call native code from the Javascript of an in-app message.