Please suggest how to prevent the app from being terminated.

my app need tracking location all the time both foreground and background. Please suggest how to prevent the app from being terminated. or detect when app is terminated.

Answered by Engineer in 850520022

The next question is, what were you hoping you could do once you detect the app has been terminated? If all you want to do is to ensure you can still track location after the app is terminated, you don't need to do anything.

The CLBackgroundActivitySession API will relaunch your app after termination, and you can continue tracking location after a small disruption due to the termination (which you cannot prevent)

Handling location updates in the background is a good start.


Argun Tekant /  DTS Engineer / Core Technologies

Please suggest how to prevent the app from being terminated.

You can’t prevent an app from being terminated. Remember that termination is driven by two criteria:

  • System resources
  • The user

Even if you avoid any system resources problems, the user will always be able to terminate your app. It’s their iPhone after all.

or detect when app is terminated.

I’m not sure what you mean by this. If your app is terminated, it’s not running, so how can it detect anything?

OTOH, if you’re asking whether it’s possible for the app, when it’s next launched, to determine whether it terminated cleanly, that’s a different story and there are various options in this space. Lemme know if you’re interested in hearing my thoughts on those options.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

The next question is, what were you hoping you could do once you detect the app has been terminated? If all you want to do is to ensure you can still track location after the app is terminated, you don't need to do anything.

The CLBackgroundActivitySession API will relaunch your app after termination, and you can continue tracking location after a small disruption due to the termination (which you cannot prevent)

Handling location updates in the background is a good start.


Argun Tekant /  DTS Engineer / Core Technologies

Please suggest how to prevent the app from being terminated.
 
 
Q