In the shouldShowMessage
function of the MessagingDelegate
, call public void handleJavascriptMessage(final String name, final AdobeCallback<String> callback)
to register your handler.
The name of the message you intend to pass from the JavaScript side should be specified in the first parameter.
The following example shows a handler that dispatches a decisioning.propositionInteract
Experience Event natively when the JavaScript of the in-app message posts a myInappCallback
message:
Java
Copied to your clipboard@Overridepublic boolean shouldShowMessage(FullscreenMessage fullscreenMessage) {Message message = (Message) fullscreenMessage.getParent();// in-line handling of JavaScript callsmessage.handleJavascriptMessage("myInappCallback", new AdobeCallback<String>() {@Overridepublic void call(String content) {System.out.println("JavaScript body passed to native callback: " + content);message.track(content, MessagingEdgeEventType.IN_APP_INTERACT);}});}
In the shouldShowMessage
function of the MessagingDelegate
, call handleJavascriptMessage(_:withHandler)
to register your handler.
The name of the message you intend to pass from the JavaScript side should be specified in the first parameter.
The following example shows a handler that dispatches a decisioning.propositionInteract
Experience Event natively when the JavaScript of the in-app message posts a myInappCallback
message:
Swift
Copied to your clipboardfunc shouldShowMessage(message: Showable) -> Bool {let fullscreenMessage = message as? FullscreenMessagelet message = fullscreenMessage?.parent// in-line handling of JavaScript callsmessage?.handleJavascriptMessage("myInappCallback") { contentprint("JavaScript body passed to native callback: \(content ?? "empty")")message?.track(content as? String, withEdgeEventType: .inappInteract)}return true}