4

We want to be able to send a notification to the device when our app is terminated on user's device (not paused).

On iOS this is when you double click the home button and swipe up on the app, and Android this happens then you press the Menu button and swipe the app to the right.

In Cordova, there are the following events:

  • deviceready
  • pause
  • resume
  • backbutton
  • menubutton
  • searchbutton
  • startcallbutton
  • endcallbutton
  • volumedownbutton
  • volumeupbutton
  • activated

None of these events will fire when the app is terminated. The closest event is pause, this is fired when the app is terminated, but also when the app is moved into the background, and there isn't a way to tell which one is happening. Plus any processes that need to happen will only happen when the app is un-paused later.

My question is, how can my server know (or be notified) when you have terminated the app, in a reliable way. In order for me to be able to send a push notification.

gunwin
  • 4,578
  • 5
  • 37
  • 59
  • On Android, what you want is unlikely to be supported. Processes are simply terminated. Your app will be told when your activity is being destroyed (usually), but that will happen for other reasons as well. – CommonsWare Mar 16 '17 at 16:38

1 Answers1

2

This is not possible on iOS; the operating system may signal in advance with a low memory warning, but that doesn't mean the app will be terminated.

On Android, Cordova does not offer any support natively for this. You might be able to accomplish something with plugins and the information here: How to handle code when app is killed by swiping in android?

Community
  • 1
  • 1
Kerri Shotts
  • 2,372
  • 1
  • 17
  • 19