Proper way to exit iPhone application?
Have you tried exit(0)
?
Alternatively, [[NSThread mainThread] exit]
, although I have not tried that it seems like the more appropriate solution.
Quit iOS Application Programmatically with UIAlertView
See QA1561:
Q: How do I programmatically quit my iOS application?
A: There is no API provided for gracefully terminating an iOS
application.In iOS, the user presses the Home button to close applications. Should
your application have conditions in which it cannot provide its
intended function, the recommended approach is to display an alert for
the user that indicates the nature of the problem and possible actions
the user could take — turning on WiFi, enabling Location Services,
etc. Allow the user to terminate the application at their own
discretion.
iOS: Exit from the app to Home Screen programmatically with gracefully exit with animation?
Code:
@IBAction func minimizeOrKillApp(){
UIControl().sendAction(#selector(URLSessionTask.suspend), to: UIApplication.shared, for: nil)
//Comment if you want to minimise app
Timer.scheduledTimer(withTimeInterval: 0.2, repeats: false) { (timer) in
exit(0)
}
}
Download sample code
It is not recommended and your app will be rejected. We all are the developers and We know to how to approve it from reviewer team
Apple developer question
exit application when click button - iOS
exit(X)
, where X is a number (according to the doc) should work.
But it is not recommended by Apple and won't be accepted by the AppStore.
Why? Because of these guidelines (one of my app got rejected):
We found that your app includes a UI control for quitting the app.
This is not in compliance with the iOS Human Interface Guidelines, as
required by the App Store Review Guidelines.Please refer to the attached screenshot/s for reference.
The iOS Human Interface Guidelines specify,
"Always Be Prepared to Stop iOS applications stop when people press
the Home button to open a different application or use a device
feature, such as the phone. In particular, people don’t tap an
application close button or select Quit from a menu. To provide a good
stopping experience, an iOS application should:Save user data as soon as possible and as often as reasonable because
an exit or terminate notification can arrive at any time.Save the current state when stopping, at the finest level of detail
possible so that people don’t lose their context when they start the
application again. For example, if your app displays scrolling data,
save the current scroll position."> It would be appropriate to remove any mechanisms for quitting your
app.
Plus, if you try to hide that function, it would be understood by the user as a crash.
Exit iPhone app, from tab bar controller?
I can't express how strongly I wouldn't recommend this - just DON'T
This will get your app rejected from the App Store in the Apple App Store Review Process.
If you insist on it though you could use exit(0);
If the user wishes to exit your app they have the Home button at the bottom of the device so there is no need to do this at all, it will create confusion and and look as if the app has crashed.
See this, it states.
There is no API provided for gracefully terminating an iOS application.
Warning: Do not call the exit function. Applications calling exit will appear to the user to have crashed, rather than performing a graceful termination and animating back to the Home screen.
So this means there is no Public API that will allow you to do this gracefully so your app would get rejected under
2.5 - Apps that use non-public APIs will be rejected
From source Apple Review Guidelines
Basic definition of exit()
exit
. The exit statement terminates your program with an exit code. Its prototype isvoid exit(int exitcode);
exit
is used by some operating systems and may be used by calling programs. By convention, anexit
code of0
means that the program finised normally, and any other value means that some error or unexpected results happened.
Also another source that says don't use it is here. That is basically all of the Apple Documentation saying under no circumstance should you be exiting the app programmatically.
ios simulator: how to close an app
You can also do it with the keyboard shortcut shown under the simulator menu bar (Hardware-> Home).
The shortcut is ⌘+⇧+H, but you need to hit H twice in a row for it to simulate the double press that shows the apps.
How to exit an IOS application when License Agreement is not accepted by user?
Do not crash or force close or find ways to close your application. If user's doesn't accept the agreement then they might not be interested in using your application eventually they will delete it. BUT, do as the protocols say, Display an agreement alert (if you already have an EULA) then point towards the same and ask user that they will have to accept the agreement in order to use the application.
Other ways could be, give a preview of some of the screens (for those who doesn't accept the EULA), if they like your screens then ask for agreement acceptance.
Hope it helps.
What is the proper UX for user to exit an iPhone app?
To send an app to the background, hitting the home button is sufficient.
To quit an app, tapping the home button twice shows you all the open apps; you can then swipe an app to "kill" (terminate) it.
However, here is a recent post by the excellent John Gruber explaining why killing an app should only be a last resort: https://daringfireball.net/2017/07/you_should_not_force_quit_apps
Note: on the iPhone Simulator, the command-shift-H key combo is equivalent to hitting the home button.
Related Topics
Download Array of Images as Byte Array and Convert to Images
Nsattributedstring Click Event in Uilabel Using Swift
The Simplest Way to Resize an Uiimage
Can You Animate a Height Change on a Uitableviewcell When Selected
Convert Utf-8 Encoded Nsdata to Nsstring
How to Check When a Uitextfield Changes
Iphone 6 Plus Resolution Confusion: Xcode or Apple'S Website? For Development
How to Parse a Json File in Swift
Registering For Push Notifications in Xcode 8/Swift 3.0
How to Center Horizontally Uicollectionview Cells
Ios Swift - Objective C Code Migration to Swift
How to Get the Indexpath.Row When an Element Is Activated
How to Make Http Request in Swift
Ios Upload Image and Text Using Http Post
Can You Build Dynamic Libraries For iOS and Load Them At Runtime