0

We have a GPS tracking type iOS app which runs in the background. We are seeing infrequent cases where the app appears to be getting terminated with the applicationWillTerminate method being called while the tracking process is taking place.

We have more or less ruled out low RAM as the reasons. Also definitely not a battery level issue or users terminating the app.

Any suggestions what would be the next most likely causes for iOS to terminate the app?

Some thoughts we had were CPU usage, phone temperature level or simply because the app is running in the background for extended periods (e.g. days or weeks).

Are any of these likely or even possible causes for iOS to terminate the app?

Uwe
  • 41,420
  • 11
  • 90
  • 134
Spook
  • 1
  • 1
  • I think you're looking at this wrong. Your app can _always_ be terminated in the background, for any reason the system feels like. You can't prevent this or second-guess it. You shouldn't be expecting it _not_ to be terminated. – matt Aug 24 '17 at 03:21
  • However, this method may be called in situations where the app is running in the background (not suspended) and the system needs to terminate it for some reason..https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623111-applicationwillterminate – Nauman Malik Aug 24 '17 at 08:15

1 Answers1

0

From Apple's Background Execution docs:

Do minimal work while running in the background. The execution time given to background apps is more constrained than the amount of time given to the foreground app. Apps that spend too much time executing in the background can be throttled back by the system or terminated.

Also, I assume you've verified you're not running afoul of the below (from the same doc):

Each call to the beginBackgroundTaskWithName:expirationHandler: or beginBackgroundTaskWithExpirationHandler: method generates a unique token to associate with the corresponding task. When your app completes a task, it must call the endBackgroundTask: method with the corresponding token to let the system know that the task is complete. Failure to call the endBackgroundTask: method for a background task will result in the termination of your app.

Smartcat
  • 2,834
  • 1
  • 13
  • 25