This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Exit application in iOS 4.0
I have a AlertView which displays some text and an "OK" button. Is there any way to exit application when clicked on OK button?
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.
You can use exit method to quit an ios app :
exit(0);
You should say same alert message and ask him to quit
Another way is by using [[NSThread mainThread] exit]
However you should not do this way
According to Apple, your app should not terminate on its own. Since the user did not hit the Home button, any return to the Home screen gives the user the impression that your app crashed. This is confusing, non-standard behavior and should be avoided.
Related
This question already has answers here:
Proper way to exit iPhone application?
(24 answers)
Closed 3 years ago.
I'm allowing language change feature inside my application. As user select new language feature inside the application I need to quit the application and user will have to start it again. For quitting I'll show an alert to user that you have to restart the application for language change to complete.
Now how can I use manual termination of iOS app and make it approve from Apple.
PS: Facebook do the same for language change. They tell the user that app needs to restart for language change to take place. Some other apps also kills the application on some alert tap.
exit(0)
you can solve your problem by this, but this is forbidden by Apple. You should set your app to your Home page when you change your language.
let viewController = HomeViewController()
UIApplication.shared.keyWindow.rootViewController = viewController
Ankur gave you the correct answer: You can use exit to terminate your app but Apple does not allow apps to terminate themselves. Your app will be rejected from the app store if you do that.
Instead, you should refactor your app so you have the ability to tear down your entire UI and rebuild it. Delete all your view controllers and replace the root view controller as Ankur says.
I'm developing a WatchKit app that I want to stay in focus until the user actively selects another app or goes back to the watch using the digital crown. Just like with the built-in Workout app.
I don't want the app to be visible on screen forever, just that when I look at the watch after some minutes I want to have updated information for my app without having to go back to the app manually due to automatic switch to the watch face.
I don't think you can control this in your app, at least not in WatchOS 1. The only way I think this can be done is for the user to select "Resume To: Last Used App" in Settings > Activate on Wrist Raise.
Apps such as Nike+ currently advise users to change this setting before starting a run.
WatchOS 2 allows apps to register as fitness apps, that will contribute as a workout and will resume when the watch is activated / raised.
I have a view containing 4 buttons:
Home
Lock
Volume up
Volume down
all I'm trying to make is that when you press one of these buttons, my app should do some communication with the device to simulate one of these buttons.
Example: If I click the home button exists within my app, is the same as I press home button in device.
This kind of thing is possible? jailbreak is necessary for this?
None of these functions are available to you if you want to get your app accepted into the App Store. For a while some apps accessed private API's in AVSystemController however it seems recently apps using this method are being rejected. (Although some apps still using the method seem to be left in the app store)
If you want to go down the jailbreak route you'll have to dig into private API's and the headers of the various frameworks.
Also just a note, Apple provides some sort of interface like this through their accessibility options.
To do what you are after would go against Apple Review Guidelines so it will get your app rejected under
2.5 - Apps that use non-public APIs will be rejected
You are not allowed to take the functionality of the Home and Lock away from these buttons and put it within your application.
Though I will not say it is impossible to do if your app is for jailbroken devices. Such as to exit your app you can do exit(0); though I still wouldn't recommend it as it makes it look as though your app has crashed when it hasn't.
For the volume control you can do this with the use of MPVolumeView I would recommend having a read of the Apple Documentation and this question iOS: Accessing device hardware audio volume control
This question already has answers here:
Proper way to exit iPhone application?
(24 answers)
Closed 9 years ago.
I have a tab based app, which last tab button is "Exit" how can I quite iPhone App, on click of that last tab bar?
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 is void exit(int exitcode);
exit is used by some operating systems and may be used by calling programs. By convention, an exit code of 0 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.
We can not send app in background or we can not quit app because Quitting your application or sending it to the background programmatically is a violation of the iOS Human Interface Guidelines, because people tend to interpret this as a crash and apple never allows such apps.
You can exit an iOS Application with the following code
exit(0)
However,
From Apple's Human User Guidelines...
Don’t Quit Programmatically
Never quit an iOS application programmatically because people tend to
interpret this as a crash. However, if external circumstances prevent
your application from functioning as intended, you need to tell your
users about the situation and explain what they can do about it.
Depending on how severe the application malfunction is, you have two
choices.
Display an attractive screen that describes the problem and suggests a
correction. A screen provides feedback that reassures users that
there’s nothing wrong with your application. It puts users in control,
letting them decide whether they want to take corrective action and
continue using your application or press the Home button and open a
different application
If only some of your application's features are not working, display
either a screen or an alert when people activate the feature. Display
the alert only when people try to access the feature that isn’t
functioning.
!!! PLEASE DONT DO IT !!!
an iphone app should not be terminated by user! Your app will be rejected!
check UITabBarDelegate
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
if( item == exitItem ) {
exit(0);
}
}
I have an app that runs for a while, but needs to be reset every day, because it's lifecycle is a bit different than most other apps. It seems that the easiest way to do this is to kill the app and re-launch it.
I found a solution that kills the app when the home button is tapped:
In your application's Info.plist, add a boolean key
UIApplicationExitsOnSuspend with the value YES
This is not something that I want to do. I need to give the user an option to kill/reset the app before it is used. I can certainly ask the user to double tap the home key and kill the app with a long press>x. Yet this is too complex for some users.
Another simple solution would be to have a button do something crashworthy, like divide by 0, although I'm not sure if the app store would penalize my app for "crashing" every single day for all users.
Has anyone found a way to add an "exit" button to an iPhone app? In android, I could do system.exit(0), which worked. What's the iPhone alternative?
iOS Human Interface Guide says -
Don’t Quit Programmatically
Never quit an iOS application programmatically because people tend to
interpret this as a crash. However, if external circumstances prevent
your application from functioning as intended, you need to tell your
users about the situation and explain what they can do about it.
Depending on how severe the application malfunction is, you have two
choices. ...
exit(0); can terminate the application (0 is a normal code), but Apple don't like this approach, and the application would be rejected in review.