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.
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