Last active
February 8, 2016 22:26
-
-
Save gbuesing/da5f195289f1ec6b09e3 to your computer and use it in GitHub Desktop.
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
// delare WKScriptMessageHandler as delegate | |
// add to WKWebViewConfiguration init: | |
configuration.userContentController.addScriptMessageHandler(self, name: "log") | |
// MARK: WKScriptMessageHandler | |
func userContentController(userContentController: WKUserContentController, didReceiveScriptMessage message: WKScriptMessage) { | |
if (message.name == "log") { | |
print(message.body) | |
} | |
} |
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
function logObject(obj) { | |
window.webkit.messageHandlers.log.postMessage(obj); | |
} | |
document.addEventListener('turbolinks:load', function() { logObject( window.location.toString() ) }, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment