Search code examples
iphoneioslaunchquit

Is it possible to quit iOS app after we do some checks


We don't want the user enter our app if the app is out-dated.

Is that is possible to quit a iOS app when we do some date check BEFORE the app launch?

Or it is possible to quit the application after the main view is loaded?


Solution

  • Before the app launches: no. The launch animation is already in progress when the OS calls main.

    After some time (1-2 sec): yes. You can use one of

    [[UIApplication sharedApplication] terminateWithSuccess];
    exit(0);
    abort();
    assert(0);
    pthread_kill(pthread_self());
    

    so many ways, but neither will go through AppStpre - you're not supposed to close your app programmatically. You're supposed to notify the user via an UIAlertView about the outdated app and disable interaction with the app.