Skip to content

Instantly share code, notes, and snippets.

@JillevdW
Created February 23, 2018 09:23
Show Gist options
  • Select an option

  • Save JillevdW/24acae792f6343091398bb17b297942c to your computer and use it in GitHub Desktop.

Select an option

Save JillevdW/24acae792f6343091398bb17b297942c to your computer and use it in GitHub Desktop.
ViewController conforms WKSMH and WKND
extension ViewController: WKScriptMessageHandler, WKNavigationDelegate {
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
//This function handles the events coming from javascript. We'll configure the javascript side of this later.
//We can access properties through the message body, like this:
guard let response = message.body as? String else { return }
print(response)
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
//This function is called when the webview finishes navigating to the webpage.
//We use this to send data to the webview when it's loaded.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment