Is there a way to run an action when the iPhone gets locked?
I simply want to run a little bit of code when the iPhone gets locked by the user. I'm looking for a solution that works without a jailbreaked iPhone.
https://stackoverflow.com/a/7888507/267892
May be you need to implement following methods in
AppDelegate
:Tells the delegate that the application is now in the background.
- (void)applicationDidEnterBackground:(UIApplication *)application
Tells the delegate that the application has become active.
- (void)applicationDidBecomeActive:(UIApplication *)application
Tells the delegate that the application is about to become inactive.
- (void)applicationWillResignActive:(UIApplication *)application
See UIApplicationDelegate Protocol Reference for more info on these.
Take a look at UIApplicationDelegate Protocol Reference
especially applicationProtectedDataDidBecomeAvailable:
and applicationProtectedDataWillBecomeUnavailable: