How do I force the app to always start from scratch when it comes back from the background?

I am working on an application that needs to run through a protocol from start to finish. How to make the application always start over when returning from the background, no matter where it was left. Thanks to

+3


source to share


3 answers


If your goal is to restart your application from scratch on every start, just add / change the key UIApplicationExitsOnSuspend

to YES

in info.plist file



Here's the relevant link in the documentation http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html

+8


source


One option is to use exit()

. However, this method is only useful for testing / programming. Apple will not agree that you are in your code.

Another option is to create a global session similar to the method used by most social media APIs and in your app delegate section:

- (void)applicationDidEnterBackground:(UIApplication *)application

      



set the global session private. Then just set the protocol logic to restart if the session is closed.

I hope this helps!

0


source


write your app start code in applicationDidBecomeActive

because this method calls the time when you start your app for the first time as well as when you cames from the background

0


source







All Articles