0

My iOS app is running in background (with location services permissions) and I am trying to determine if the app is terminated by the user or they system. In the case of a user terminating with the app switcher, I'd want to clean up some location region monitoring (ideally immediately, or less ideally on a reload of the app), because I assume the user wants a clean termination. In the case of a system termination, I want to leave the region monitoring in place. The problem is that in both cases (for an app running in background - as opposed to suspended, where one can check if the state change to suspended occurred before termination -), applicationWillTerminate is called for both a user and system termination. In this particular case, that's problematic because I'm unable to determine whether it's system or not. Is there any way to make this differentiation? Or, perhaps another angle: how can one detect if the previous app termination occurred due to a crash (in this case, though not as ideal, at least clean up can be done on reload of the app).

I should clarify as an edit, that what I mean by user force quit, is that the user swipes up in the multitasking screen. This generates a call to applicationWillTerminate. A force quit by holding down the home button after holding down the power off button, doesn't call applicationWillTerminate, but I'm not concerned about this case - What I would ideally like to determine is if the user terminated in the multitasking screen (or whether the os killed that app for, say, memory issues).

Samaga
  • 98
  • 5
  • You can detect a crash using a library such as https://www.plcrashreporter.org – rmaddy Mar 25 '15 at 18:42
  • Thanks: Unfortunately, it looks like in the case of a termination using the multitasking screen, the 0xdeadfa11 termination exception isn't generated. The exception is only generated in the power button force quit case. – Samaga Mar 26 '15 at 16:34

0 Answers0