iOS-WKWebViewBridgeExample-Swift
iOS-WKWebViewBridgeExample-Swift copied to clipboard
A sample app in Swift that demonstrates how to bridge between JS-Native code using WKWebViews in iOS8.
for example a promise ```swift let code = "Promise.resolve({msg: 'hello world'})" let js = "Promise.resolve(" + code + ").then(data => webkit.messageHandlers.bridge.postMessage({i: " + i + ", data}))" webview.evaluateJavaScript(js) ```
You should add the following in the view controllers deinit deinit { webView.configuration.userContentController.removeScriptMessageHandlerForName("buttonClicked") webView.configuration.userContentController.removeAllUserScripts() }