ionic-team / ionic-v1

The repo for Ionic 1.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
Other
193 stars 187 forks source link

$ionicHistory.clearHistory() doesn't work android 6.0 and above #263

Open jgw96 opened 7 years ago

jgw96 commented 7 years ago

From @PterPmnta on June 5, 2017 0:35

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 when the view is the menu, but don't work, just return to the backView, and this don't be happened.

The capture of the backButton in android don't work,

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);

    }
}

Your system information:

Copied from original issue: ionic-team/ionic#11924

jgw96 commented 7 years ago

From @rapropos on June 5, 2017 3:8

Should be migrated to ionic-v1.

PterPmnta commented 7 years ago

@jgw96 i am using ionic v1, i find the solution, create a new project, with android 6.2.1