Exit app and dont save history

I wonder how I keep my application save the record and that when in a view prederteminada by giving click the Back button exit the app android

##App.js##

`angular.module(‘unicesarApp’, [‘ionic’, ‘ngCordova’])

.run(function($ionicPlatform) {

$ionicPlatform.ready(function ($state) {

if (window.cordova && window.cordova.plugins.Keyboard) {
    
       cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
       cordova.plugins.Keyboard.disableScroll(true);   
    
} 
  
$ionicPlatform.registerBackButtonAction(function (event) {
    
        if ($state.current.name == 'menuestu' || $state.current.name == 'menuprof') {
            navigator.app.exitApp();
        } else {                
            navigator.app.backHistory();
        }
    
}, 100);

});

});`

Please switch with ionic v2. every solution is there. now community working with v2 .

@PterPmnta
use Ionic History .
$ionicHistory.clearCache();
$ionicHistory.clearHistory();
You can clear history in any controller and exit the application.
And cordova dialog plugin is not needed to exit the app ionic handles the navigator.app.backHistory(); and navigator.app.exitApp();
For more go through the official documentation .
http://ionicframework.com/docs/api/service/$ionicHistory/

But how advanced is the beta version of ionic v2 , mainly I need to use POST and GET requests , SQLLite , Datepicker , LocalStorage , it is recommended , and most importantly , can be used ngCordova or is there something different for this version of ionic.

Also I have the disadvantage of not knowing angular 2, then I can not jump that fast , learn first angular 2 and then go toward instilling version 2 of ionic

I have this

$ionicPlatform.ready(function () { var closeApp = false; $ionicPlatform.onHardwareBackButton(function () { if ($ionicHistory.currentStateName() == 'menuestu') { if (closeApp === true) { navigator.app.exitApp(); } else { closeApp = true; $timeout(function () { closeApp = false; }, 2000); notifications.notify("Presione nuevamente para salir", "short", "bottom"); } } }); });

But dont work

Try this,

// backbutton register to confirm exit
$ionicPlatform.registerBackButtonAction(function (e) {
    e.preventDefault();
    function showConfirm() {
        var confirmPopup = $ionicPopup.show({
            title: 'Exit App?',
            template: 'Are you sure you want to exit?',
            buttons: [{
                    text: 'Cancel',
                    type : '',
                }, {
                    text: 'Ok',
                    type : 'button-calm',
                    onTap: function () {
                        ionic.Platform.exitApp();
                    }
                }]
        });
    };
    if ($ionicHistory.backView()) {
        $ionicHistory.backView().go();
    } else {
        showConfirm();
    }
    return false;
}, 101);

And How exit the app in V2 ? :slight_smile: