Native Android: WebView
Create a pair of WebMessagePorts with WebView#createMessageChannel(). Set a WebMessageCallback on the first WebMessagePort
, which will receive events from the embedded UX. Wrap the second WebMessagePort
in an array, then wrap that in a WebMessage to send the port to the embedded UX:
WebMessagePort[] channel = webView.createMessageChannel();
channel[0].setWebMessageCallback(webMessageCallback);
WebMessage webMessage = new WebMessage("", Array.of(channel[1]));
webView.postWebMessage(webMessage, embeddedSessionUrl);
When your callback receives a WebMessage, its getData()
method will return a JSON string. See Component Events for details of the data structure of that JSON string.
Updated 24 days ago