2

Is there a way to check when a user has shutdown/closed my app?

I want to save some data when this happens and I'm not sure if there's a way to do it.

thefan12345
  • 136
  • 16
  • possible duplicate of [iOS - detect when application exits](http://stackoverflow.com/questions/9447690/ios-detect-when-application-exits) – Black Frog Apr 20 '15 at 11:48
  • I think you're right Black Frog, should I delete this post? – thefan12345 Apr 20 '15 at 11:52
  • 3
    Don't delete. Some searches will land on your question which will help people by pointing them in the right direction. – Black Frog Apr 20 '15 at 11:59
  • How on earth are those duplicates? This seems to ask how to detect if a user KILLS an app. That is just to detect if a user LEAVES an app. –  May 20 '20 at 16:18

2 Answers2

5

Yes, you can do this in - (void)applicationWillTerminate:(UIApplication *)application method of the AppDelegate.

Save data, user settings in this method.

David Ansermot
  • 6,052
  • 8
  • 47
  • 82
2

When a user closes the app, - (void)applicationWillTerminate:(UIApplication *)application gets called, which is located in the AppDelegate. You can do the needful in that.

Kunal Shah
  • 104
  • 5