Skip to content

Latest commit

 

History

History
89 lines (54 loc) · 2.61 KB

File metadata and controls

89 lines (54 loc) · 2.61 KB

Message

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.

Public variables

id

Identifier of the Message.

public var id: String

autoTrack

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

view

Holds a reference to the message's WKWebView instance, if it exists.

public 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.

public 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.

public func dismiss(suppressAutoTrack: Bool? = false)
Parameters
  • suppressAutoTrack - if set to true, the "decisioning.propositionDismiss" Edge Event will not be sent regardless of the autoTrack setting.

track(_:withEdgeEventType:)

Generates and dispatches an Edge Event for the provided interaction and eventType.

public 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.

public 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 Message's Javascript

For more information on how to use handleJavascriptMessage, read Call native code from the Javascript of an in-app message.