I am working on state preservation. I would like to preserver the state of my app if
1.. when it is in background, it is killed by IOS due to the lack of memory
I don't want to preserv the state if
2.. when it is in background, it is killed by user
3.. when it is in foreground, it is killed by user
As mentioned by @matt, 1 and 3 can be easily distinguished: when an app is in foreground, if it is killed by user, the state will not be preserved; The app's state is preserved at the moment it goes into background.
My question is: when an app is already in the background, how to determine if it is killed by IOS or by user.