How do I force an app to always start from scratch when it returns from the background?

人走茶凉 提交于 2019-12-05 18:31:28

If your goal is to restart the app from scratch at every start up, simply add/change the key UIApplicationExitsOnSuspend to YES in your info.plist file

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

One option is to use exit(). However, that method is only useful for testing/programming purposes. Apple will not accept that being in your code.

Another option would be to create a global session similar to the method used by most social media API's, and in your App Delegate's:

- (void)applicationDidEnterBackground:(UIApplication *)application

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

I hope that helps!

write your application starting code in applicationDidBecomeActive method, because this method calls both time when you start your application first time & also when you cames from background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!