5

How can I detect when a user exits the application? (hitting the home button) And how can I detect when the relaunch it? (clicking the icon)

*I'm not talking about users manually quitting the app by holding the home button and then making the icons wiggle and deleting the app instance from the sub-dock. i'm talking about just temporarily exiting the app buy clicking the home button.. maybe sending a text or whatnot then coming back to the app.

Thanks!

Jonathan Leffler
  • 698,132
  • 130
  • 858
  • 1,229
Albert Renshaw
  • 16,406
  • 17
  • 99
  • 182

2 Answers2

13
- (void)applicationDidEnterBackground:(UIApplication *)application

and

- (void)applicationDidBecomeActive:(UIApplication *)application

In your AppDelegate.m

- (void)applicationWillTerminate:(UIApplication *)application
0xDE4E15B
  • 1,294
  • 1
  • 11
  • 25
3

There's a notification UIApplicationDidGoToBackground that fires when the home button is pressed. A similar notification tells you about going back to foreground.

Nikolai Ruhe
  • 80,564
  • 16
  • 176
  • 197