Jerry Shi Jerry Shi - 1 year ago 91
Swift Question

how to make iOS app relaunch every time after user goes back to home screen?

I am building an iOS app right now and I wanna ask how to make it relaunch every time after user goes back to the home screen. For example, you open an app, do whatever you need to do in the app and then you exit to the home screen, now you want to reopen this app, and the question is when you reopen it, how to make it forget what it was doing and start a new session?
Thanks :)

Answer Source

You can set UIApplicationExitsOnSuspend to YES in your plist file. As per documentation

UIApplicationExitsOnSuspend (Boolean - iOS) Specifies that the app should be terminated rather than moved to the background when it is quit. Apps linked against iOS SDK 4.0 or later can include this key and set its value to YES to prevent being automatically opted-in to background execution and app suspension. When the value of this key is YES, the app is terminated and purged from memory instead of moved to the background. If this key is not present, or is set to NO, the app moves to the background as usual.

It will make sure whenever app goes in background it is terminated.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download