Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quit application in titanium (iOS)

Tags:

ios

exit

titanium

What is the equivalent for iOS to:

 win.close();
 var activity = Titanium.Android.currentActivity;
 activity.finish();

Thanks!

like image 340
Sebastián Avatar asked Mar 21 '23 02:03

Sebastián


2 Answers

There isn't (in Titanium). Further, Apple explicitly discourages this:

"An iOS app never displays a Close or Quit option" - Apple, HIG p27 https://developer.apple.com/library/ios/documentation/userexperience/conceptual/mobilehig/MobileHIG.pdf

There are existing SO answers regarding this:

On the iPhone there is no concept of quitting an app. The only action that should cause an app to quit is touching the Home button on the phone, and that's not something developers have access to.

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.

See existing SO answer here: Proper way to exit iPhone application?

If, after all this, you want a non-standard, will-probably-get-your-app-rejected solution (or if your app isn't destined for the app store, and will be distributed privately through enterprise distribution or personal use), you can create a module that calls [[NSThread mainThread] exit].

like image 147
Dawson Toth Avatar answered Mar 29 '23 00:03

Dawson Toth


There is no way to close iOS application using just Titanium SDK. If you really need that you have to create your own small Titanium Module with just one method:

-(id)example:(id)args
{
    // example method
    exit(0);
    return @"Application Exit";
}

However, remember that calling exit() is strongly not recommended for iOS applications and can lead to rejection from App Store.

like image 26
daniula Avatar answered Mar 29 '23 00:03

daniula