Created
February 23, 2018 09:23
-
-
Save JillevdW/24acae792f6343091398bb17b297942c to your computer and use it in GitHub Desktop.
ViewController conforms WKSMH and WKND
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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