jcf120-cordova-plugin-customurlscheme
Version:
Launch your app by using this URL: mycoolapp://, you can add a path and even pass params like this: mycoolerapp://somepath?foo=bar
47 lines (38 loc) • 1.08 kB
JavaScript
(function () {
"use strict";
var remainingAttempts = 10;
function waitForAndCallHandlerFunction(url) {
if (typeof window.handleOpenURL === "function") {
// Clear the intent when we have a handler (note that this is only done when the preference 'CustomURLSchemePluginClearsAndroidIntent' is 'true' in config.xml
cordova.exec(
null,
null,
"LaunchMyApp",
"clearIntent",
[]);
window.handleOpenURL(url);
} else if (remainingAttempts-- > 0) {
setTimeout(function(){waitForAndCallHandlerFunction(url);}, 500);
}
}
function triggerOpenURL() {
cordova.exec(
waitForAndCallHandlerFunction,
null,
"LaunchMyApp",
"checkIntent",
[]);
}
document.addEventListener("deviceready", triggerOpenURL, false);
var launchmyapp = {
getLastIntent: function(success, failure) {
cordova.exec(
success,
failure,
"LaunchMyApp",
"getLastIntent",
[]);
}
}
module.exports = launchmyapp;
}());