Hello, everyone!
I’m trying to build my ionic app and I have to unsubscribe from push notifications after I exit it.
I wonder if there is a way to get the event of closing my app in apple devices?
Hello, everyone!
I’m trying to build my ionic app and I have to unsubscribe from push notifications after I exit it.
I wonder if there is a way to get the event of closing my app in apple devices?
There’s no such event. It would be considered a security flaw.
Closest you can get is event that tells you when the App has entered the background. Put this into your .run():
//handle Cordova resume (enter foreground) and pause (enter background events)
$ionicPlatform.on('resume', function() {
});
$ionicPlatform.on('pause', function() {
//Do something here on entering background
});
i’ve done this to handle the pause event
document.addEventListener('deviceready', function(){
document.addEventListener('pause', function(){
//Do something here on entering background
}, false);
}, false);
and it worked. i think it’s necessary to put our pause
event inside a deviceready
event.
Why would it be a security flaw?