4

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
  • 730,956
  • 141
  • 904
  • 1,278
Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195

2 Answers2

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

and

- (void)applicationDidBecomeActive:(UIApplication *)application

In your AppDelegate.m

- (void)applicationWillTerminate:(UIApplication *)application
0xDE4E15B
  • 1,284
  • 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
  • 81,520
  • 17
  • 180
  • 200