When I start app by custom scheme url,event 'deviceready' trigger,and window.handleOpenURL in the getBillFromLink() execute;
then I open a webpage and resume the app from it,but window.handleOpenURL didn't execute;function onResume and getBillFromLink will execute;
but no matter how many times I resume the app from webpage after the first time, window.handleOpenURL will execute normally;
Here are code:
$ionicPlatform.on("deviceready", function () {
document.addEventListener("resume", onResume, false);
getBillFromLink().then(function (data) {
//todo
});
});
function onResume() {
getBillFromLink().then(function (data) {
//todo
});
}
function getBillFromLink() {
var deferred = $q.defer();
$timeout(function() {
window.handleOpenURL = function(url){
if(!!url){
deferred.resolve(url);
}else{
deferred.reject(url);
}
};
}, 0);
return deferred.promise;
}
how could I deal with the trouble?
thanks for your advice and sorry for my poor English:-)
Your issue is not linked to custom-scheme-url plugin as your apps properly starts when you call your specific URL.
I assume that, once the app is already started; custom-scheme-url does not trigger again your function.
You have to use a backgroundmode plugin. I suggest to use : https://github.com/katzer/cordova-plugin-background-mode
This plugin let s you define events when apps goes from background to active app. and more.