$ionicHistory.clear History() doesn't work android 6.0 and above


#1

I used Ionic 1 for development an application, all functions work fine Android 5.1<, but in android 6.0 o above, i try to exit of the App but don’t work, just return to the backView.

###Module specification

angular.module('historialApp', ['ionic', 'ngCordova'])
    .controller('borrarHistorial', borrarHistorial)
    .factory('salirApp', salirApp);

###Controller

borrarHistorial.$inject = ['$scope', '$ionicHistory', 'salirApp', '$ionicPopup', '$state', '$timeout', '$window'];

function borrarHistorial($scope, $ionicHistory, salirApp, $ionicPopup, $state, $timeout, $window) {

    salirApp.salida();
    $ionicHistory.clearHistory();

}

Factory

salirApp.$inject = ['$ionicPlatform', '$ionicHistory', '$timeout', '$cordovaSQLite'];

function salirApp($ionicPlatform, $ionicHistory, $timeout, $cordovaSQLite) {

    function salida() {

        var BackButton = 0;

        $ionicPlatform.registerBackButtonAction(function() {

            if ($ionicHistory.currentStateName() === 'menuestu' || $ionicHistory.currentStateName() === 'menuprof') {

                if (BackButton === 0) {

                    BackButton++;
                    window.plugins.toast.showLongCenter('Presione nuevamente para salir');

                    $timeout(function() {
                        BackButton = 0;
                    }, 2500);

                } else {
                    navigator.app.exitApp();
                }

            } else {
                if ($ionicHistory.currentStateName() === 'login') {
                    navigator.app.exitApp();
                } else {
                    $ionicHistory.goBack();
                }
            }

        }, 100);

    }
}