How to know whether app is terminated by user or iOS (after 10min background)

后端 未结 2 1948
一整个雨季
一整个雨季 2020-11-30 15:10

How to know whether app is terminated by user or by iOS when restart app>

\'By user\' means \"by Double-clicking Home Button and pressing - button\". killed by user<

2条回答
  •  醉梦人生
    2020-11-30 15:39

    iOS might terminate your app if system resources are low - if this happens, you will see applicationWillTerminate.

    It used to be that if a user killed the app (task manager, via the button double-click and then hits the red '-') it's a SIGKILL and applicationWillTerminate is not called. A report mid-2013 suggests this has changed and applicationWillTerminate now is called.

    You could use NSUserDefaults to write some state bit in applicationWillTerminate to note that this function was called and presumably that's a system kill rather than a user kill.

提交回复
热议问题