Drux Drux - 16 days ago 6
Javascript Question

What types (next to string) can be passed from JavaScript to Swift inside WKScriptMessage?

I know how to pass strings (e.g. from DOM text nodes) from JavaScript (inside an apps

WKWebView
) to Swift.

What other types are supported? For instance, could I pass DOM elements inside
WKScriptMessage
?

Answer

I have never seen any proper documentation for this. I have successfully put stuff in there that is JSON compatible.

I don't think a DOM element works. But just try it and see what you get back. You may have to turn it into a simpler object first in JavaScript.