1

I need to find a way to detect when a device has been locked, or else a way to detect when the device has been unlocked, and sent straight to the app where it left off. Is there some method like:

- (void)applicationDidBecomeActiveAfterLockScreen:(UIApplication *)application
Hank Brekke
  • 2,024
  • 2
  • 24
  • 33

1 Answers1

2

For detecting when phone is being unlocked and application is becoming active again, there is

- (void)applicationDidBecomeActive:(UIApplication *)application

method.

When the device is locked, a method

- (void)applicationWillResignActive:(UIApplication *)application

is called.

Both methods belong to the UIApplicationDelegate protocol.

See UIApplicationDelegate Protocol Reference.

macbirdie
  • 16,086
  • 6
  • 47
  • 54
  • Those happen at other times too, like an incoming phone call. – progrmr Jun 18 '10 at 01:14
  • is there a time limit on applicationWillResignActive, like on applicationWillTerminate, how if the function takes more than 5 seconds the function code execution is terminated. – Hank Brekke Jul 01 '10 at 18:04