Last active
June 13, 2018 08:20
-
-
Save dobreandl/fbe1bf4d06ae7a020d9f1deef9c7e12d to your computer and use it in GitHub Desktop.
This file contains 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
private func addPageHasChangedDelegateScript(wkWebController: WKUserContentController) { | |
// load the script from the file and create a WKUserScript object | |
let scriptURL = Bundle.main.path(forResource: Constants.detectPageChangeScript, ofType: "js") | |
let scriptContent = try! String.init(contentsOfFile: scriptURL!) | |
let script = WKUserScript(source: scriptContent, injectionTime: .atDocumentStart, forMainFrameOnly: false) | |
// Add the script to the WKUserContentController | |
wkWebController.addUserScript(script) | |
// Register for receiving callbacks from javascript for a notification name | |
wkWebController.add(self, name: ”notification_name”) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment