Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// delare WKScriptMessageHandler as delegate
// add to WKWebViewConfiguration init:
configuration.userContentController.addScriptMessageHandler(self, name: "log")
// MARK: WKScriptMessageHandler
func userContentController(userContentController: WKUserContentController, didReceiveScriptMessage message: WKScriptMessage) {
if ( == "log") {
function logObject(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