Quit app when pressing home
I my testing, when I exit (by pressing the home button) my app, it still is “running” in the background, thanks to the multitasking feature. However, I would like it to quit when the home button is pressed. Is this only happening to me?
Anyway, I have tracked it down to the
applicationWillResignActive and the
applicationDidBecomeActive methods in the app delegate. These get called for multitasking, but when I want to terminate, the app “resigns active.” Any guidance on this issue is greatly appreciated!
- Detecting when app is becoming active from lockscreen vs other on iOS7
- Which methods are called when user presses home button and double presses it again to return
- background audio recording in iOS
- Handling applicationDidBecomeActive - “How can a view controller respond to the app becoming Active?”
- applicationWillEnterForeground: reload Data from ViewController
- Detect if app is running in Slide Over or Split View mode in iOS 9
3 Solutions Collect From Internet About “Quit app when pressing home”
Your application can opt out of multitasking (see the appropriate section in the iPhone Application Programming Guide) by adding the
UIApplicationExitsOnSuspend key to your Info.plist and setting its value to YES.
In practice, Apple strongly recommends you not do this unless you have a very good reason for this behavior.
I think it’s more efficient to suspend an app, when pressing the “Home” button. There’s overhead in constantly launching and terminating apps. It’s worse for the iOS operating system, and it’s worse for user experience – because they need to wait for the app to launch again. Not sure what benefits you gain from terminating an app. If it’s for simulation testing, my advice is to avoid that functionality, because your testing environment should be as realistic as possible. If your purpose is to clear cache or to make updates – that can all be done programmatically from subroutines.
If you still insist on terminating an app when the user presses the “Home” button, despite the costs mentioned above – then set the
UIApplicationExitsOnSuspend to true in your Info.plist as suggested by Brad Larson.
I wouldn’t recommend trying to control the user’s HOME button… deciding for them “exit” or “suspend”.
I WOULD like to have HOME do an instant EXIT in the iPhone simulator… but haven’t found any way to do that.
- iPhone: How to send a HTTP request to a web service using Xcode
- How to install Xcode 3.2.x on Lion?
- Reconnecting to disconnected peers
- “Apple Mach-O linker command failed with exit code 1”
- screen styling when virtual keyboard is active
- Xcode build fails with “fatal error: malformed or corrupted AST file” Crashlytics.h
- Save Carbon messages XMPPFramework iOS
- Swift error: 'missing return in function'?
- Loading image from CoreData at cellForRowAtIndexPath slows down scrolling
- Sort File List in Xcode?
- Error in for loop CGFloat
- Custom NSLocalizedString?
- Getting data out of the NSURLResponse completion block
- Private func didFinishLaunchingWithOptions not being called? (Swift 3)
- UIAlertController title and message not appearing