-6

In my application i have situations when i need to force close app. What would be the best way to exit app after some kind of alert window?

Small ex.:

If user enters password 3 times wrong, i want to close app

UPD:

exit(0);

is not an option. This will close app without animation and any other related stuff

Avdept
  • 2,261
  • 2
  • 26
  • 48
  • 2
    why do you want to close the app when user enters a wrong password? you should handle all possible scenarios. You can't let users go away from your app at the initial login. – Reno Jones Jul 01 '13 at 13:35
  • Do not exit the app. If the use gets the password wrong three times in a row then tell them they've done that. No reason to throw them out of the app. – Fogmeister Jul 01 '13 at 13:37
  • its the specific of this app. There are some situatuons, which user cant handle by himself – Avdept Jul 01 '13 at 13:38

4 Answers4

7

On the SO this question is asked before so many times, you should definitely know that,

On the iPhone there is not any concept of quitting an app. The only action that should cause an app to quit is touching the Home button. Unfortunetly developers do not have access for it

According to Apple, your app must 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.

The answers given below are totaly wrong, you must not use exit function in any case, even apple will reject such kind of apps.

You can checkout apple's QA report for your reference.

Niru Mukund Shah
  • 4,637
  • 2
  • 20
  • 34
  • Please note that a "should not" is not a "must not". Meaning that you are allowed to use an `exit(0)` but you are not encouraged to do it. There are apps from big studios out there that actually do an exit. – Till Jul 01 '13 at 13:52
6

Apple review guidelines:

10.1: Apps must comply with all terms and conditions explained in the Apple iPhone Human Interface Guidelines and the Apple iPad Human Interface Guidelines

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.

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.

torip3ng
  • 585
  • 2
  • 7
2

You should not use exit(0); in your app, that means without pressing home button you should not close the application. if you exit your app manually apple will reject your application.

Venk
  • 5,949
  • 9
  • 41
  • 52
0

You can use exit(0);

I don't think apple will reject if you have a valid for your app termination. But reason should be highly valid. I have used it in one of my app and it got approved.

  • Interesting. Can you describe the scenario in which your app terminated? Thanks. – Jeremy Jul 01 '13 at 14:30
  • It was a notification app in which you can set up some alarms by just giving the appointment time. Once you set up all your alarms you can close app by clicking on a button. On that button i called Exit(0); –  Jul 02 '13 at 04:42