I need to restart my iPhone application, if it was in process and the device was locked and unlocked again. How can it be done?
            Asked
            
        
        
            Active
            
        
            Viewed 269 times
        
    0
            
            
        - 
                    maybe duplicate - http://stackoverflow.com/questions/7888490/how-can-i-detect-screen-lock-unlock-events-on-the-iphone – smartmeta Sep 26 '13 at 15:37
 - 
                    2What do you mean by "restart"? Why do you need to do it? – Wain Sep 26 '13 at 15:43
 - 
                    @Wain, I need to start the app from the very beginning, from the view controller, that was first shown in the app – Nikita Shytyk Sep 26 '13 at 15:51
 - 
                    1Is that a login screen or something? You should aim to remember where the user was and take them back there. If you need to re-authorize then show that as a modal... – Wain Sep 26 '13 at 15:54
 
1 Answers
1
            Below are the methods that are called when the app goes in the background and when its brought back in the foreground. They are defined in your appdelegate.m file:
- (void)applicationWillResignActive:(UIApplication *)application;
- (void)applicationDidEnterBackground:(UIApplication *)application;
- (void)applicationWillEnterForeground:(UIApplication *)application;
- (void)applicationDidBecomeActive:(UIApplication *)application;
You can write code in these methods to "suspend" and "restart" your application when the user locks and then unlocks the phone respectively.
Hope that gives your pointers.
        AC1
        
- 463
 - 3
 - 9