How to exit the app?

The document says:

ionic.Platform.exitApp()

, but it doesn’t work.

in 5 years i’ve never seen an app with an exit / quit button!

4 Likes

It doesn’t work in ? Android? iOS ? Chrome?

http://community.phonegap.com/nitobi/topics/how_to_exit_from_the_phonegap_app_on_android_and_ios

1 Like

@Calendee Oh, Thanks for your help. I’m sorry I didn’t express clearly the platform is, your link makes me understand it.

hey i want to close the app when user on login screen and pressed back button …how i close or exit app .???

This is what I did on a recent app built, Toaster service referred to below is just a wrapper for the cordova-plugin-x-toast functionality.

var warnedExit = false;

// capture all instances of the hardware back button and do some custom behaviors
$ionicPlatform.registerBackButtonAction(function(event) {
            // if we have reached the beginning of the history tree
            if (!$ionicHistory.backView()) {
                // check to see if we have warned them before
                if (!warnedExit) {
                    // stop the navigation if the App is about to exit
                    event.preventDefault();

                    // flag that we have warned the user
                    warnedExit = true;

                    // show the instruction to press back again to exit
                    Toaster.showLong('Press back again to exit.');

                    // give the user 3 seconds before switching the warned flag back to false and start all over again
                    $timeout(function () {
                        warnedExit = false;
                    }, 3000);
                } else {
                    ionic.Platform.exitApp();
                }
            } else {
                $ionicHistory.goBack();
            }
        }, 1000);

if (navigator) navigator.app.exitApp();