Tutorial by Examples

import UIKit import WebKit class ViewController: UIViewController, UISearchBarDelegate, WKNavigationDelegate, WKUIDelegate { var searchbar: UISearchBar! //All web-browsers have a search-bar. var webView: WKWebView! //The WKWebView we'll use. var toolbar: UIToolbar! //Toolb...
let configuration = WKWebViewConfiguration() if let path = NSBundle.mainBundle().pathForResource("customUserScript", ofType: "js"), source = try? NSString(contentsOfFile: path, encoding: NSUTF8StringEncoding) as String { let userScript = WKUserScript(source...
Messages can be sent from JavaScript using the following code window.webkit.messageHandlers.{NAME}.postMessage() Here how to create a script message handler to handle the messages: class NotificationScriptMessageHandler: NSObject, WKScriptMessageHandler { func userContentController(userCon...

Page 1 of 1