Based on the documentation for cordova events and the Platform class I conclude that there is no way to intercept my app closing (you know when you double click home button and swipe up to kill the app) on iOS.
In my app I would like to perform this.storage.set('endTime',new Date()) but cannot think of a way to accomplish this.
One way would be to call this x second and as it stops updating because the app is not running any more, you will know the last active value on next start. But this will cost your users lots of battery and they will probably hate your app.
A less user hostile way would be to do this on every interaction in your app. This is a better metric anyway, because you don’t want to know the user had your app open for 4 hours but did nothing (I assume).
A even less hostile way on every significant interaction. You want to know this because of some reason, which is probably when the user last did something (I assume).
Ah… So then he’ll have to figure it out from his back-end or some other solution. Hm, will the service-workers work? They’re pretty active keeping tabs on the apps state.
FYI this app is basically maintaining several stop watches which are capturing end times. the app has low accuracy requirement so is why I set to 5 seconds.
I guess it depends on what you mean by “back-end”, but with a normal REST server the back-end itself can keep track of timestamps itself without the app having to do anything.
One thing that might be worth at least investigating is whether Platform.pause() fires at this point.