Created
February 5, 2014 07:39
-
-
Save azu/8818908 to your computer and use it in GitHub Desktop.
easy setup example
https://github.com/marcuswestin/WebViewJavascriptBridge
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
function connectWebViewJavascriptBridge(callback) { | |
var rightBack = function (bridge) { | |
bridge.init(function (message, responseCallback) { | |
if (responseCallback) { | |
responseCallback("Right back atcha") | |
} | |
}); | |
callback(bridge); | |
}; | |
if (window.WebViewJavascriptBridge) { | |
rightBack(WebViewJavascriptBridge) | |
} else { | |
document.addEventListener('WebViewJavascriptBridgeReady', function () { | |
rightBack(WebViewJavascriptBridge) | |
}, false) | |
} | |
} | |
connectWebViewJavascriptBridge(function (bridge) { | |
var appSchemeList = ["com.apple.safari"]; | |
bridge.callHandler('isInstalledApp', appSchemeList, function (responseData) { | |
document.querySelector("#output").textContent = JSON.stringify(responseData, null, 4); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment