Hacker News new | ask | show | jobs
by _rend 1412 days ago
Only intentionally, via setup from a hosting app. If an app uses a WKWebView to display web content, it can use WKUserContentController[1] to inject scripts and additional content into the page dynamically, and can inject functions into JS[2] which will trigger native callback handlers when called.

If your app uses the JavaScriptCore[3] framework to run JS in a VM in-process directly, you have even more options for interfacing between JS and native code.

Note that this has to be explicitly hooked up by the app (i.e., none of this applies within, say, Safari).

[1]: https://developer.apple.com/documentation/webkit/wkuserconte...

[2]: https://developer.apple.com/documentation/webkit/wkuserconte...

[3]: https://developer.apple.com/documentation/javascriptcore