Skip to content

Instantly share code, notes, and snippets.

@azu
Created February 5, 2014 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azu/8818908 to your computer and use it in GitHub Desktop.
Save azu/8818908 to your computer and use it in GitHub Desktop.
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