Skip to content

Instantly share code, notes, and snippets.

@movii
Created June 9, 2018 15:54
Show Gist options
  • Save movii/d91453b9819f0711b1205ed5249d205a to your computer and use it in GitHub Desktop.
Save movii/d91453b9819f0711b1205ed5249d205a to your computer and use it in GitHub Desktop.
extension NativeInvokeJavaScriptBrowserViewController: WKNavigationDelegate {
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
switch requestJavaScriptMethod!
{
case "SayHelloTo":
wkWebView.evaluateJavaScript("sayHelloTo('Lien')")
case "SayHelloToWithReply":
wkWebView.evaluateJavaScript("sayHelloToWithReply('Lien')") { (any,error) -> Void in
print("\(any as! String)")
}
default:
wkWebView.evaluateJavaScript("sayHello()")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment