Check if app is opened by push notification

Hi,

I'm using Ionic and PushPlugin v2.1.2 and need to determine whether or not the app is opened by push notification. This is how I solved it in my code:


document.addEventListener("push-notification", function (event) {
$scope.pushColdStart = event.detail.additionalData.coldstart;
if($scope.pushColdStart) {
//Navigate to page X...
Apperyio.navigateTo('Page X', {data: event.detail.additionalData.data});
} else {
//Do something else...
}
});

//Do some stuff....

$.ajax({
//....
}).done(function(data) {
$timeout(function() {
if(!$scope.pushColdStart) {
//Navigate to page Y...
Apperyio.navigateTo('Page Y', {});
}
}, 2000);
});


As you can see, I need to wait for 2 seconds to determine if the 'push-notification' eventlistener has been called. My users are complaining now that the app takes too long to start. Is there any other way to check if the app is opened by push notification without waiting for the push-notification eventlistener?
1 person has
this question
+1
Reply