is there a way to tell if an iOS app is closed unexpectedly?(crash, force close)

前端 未结 3 1060
悲&欢浪女
悲&欢浪女 2021-02-06 18:18

I want to do something on app start if the app is closed unexpectedly last time.(crash, force close), how can I tell it?

3条回答
  •  我寻月下人不归
    2021-02-06 18:51

    Yes, you can do it: the simplest way is to create a file with a known name in the /Documents/ directory, and delete that file upon the "normal" exit. If the file is there on launch, you know the previous exit has not been a "normal" one.

    You could update the content of the file periodically, writing the current timestamp on a timer every minute. This way you would know approximately when the abnormal exit has happened.

提交回复
热议问题