How to get JSContext from WKWebView

You cannot obtain the context, because layout and javascript is handled on another process. Instead, add scripts to your webview configuration, and set your view controller (or another object) as the script message handler. Now, send messages from JavaScript like so: window.webkit.messageHandlers.interOp.postMessage(message) Your script message handler will receive a callback: – (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message{ … Read more

How to Add a new native class to WebWorker’s context in JavaScriptCore?

There is no way to modify the WorkerGlobalScope or comparable scopes/contexts before a web worker is started in most common browser implementations. These scopes become available only to the web workers context as soon as this specific web worker is launched. The only way to use shared methods is to define them in a separate … Read more