1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
(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;
}());
|