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

前端 未结 3 972
悲&欢浪女
悲&欢浪女 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:33

    Ill post this just for future reference:

    For extra coverage check activity states with

    • (void)applicationDidBecomeActive:(UIApplication *)application
    • (void)applicationWillResignActive:(UIApplication *)application

    then use nsuserdefaults to keep track of the status

    the main difference between background checking is that these cover the edge case when the user immediately closes the app via app switcher when the app is still executing in the foreground. Also this helps for background compatible apps i think

    I think it might give you more coverage between a crash and a force close with these... although i haven't tested running out of battery

提交回复
热议问题