I try to Exit app from a specific page(HometabsPage) using Hardware Back Button. I use below code:
var lastTimeBackPress = 0;
var timePeriodToExit = 2000;
platform.registerBackButtonAction(() => {
let view = this.nav.getActive();
if (view.component.name == 'SignInPage' ) {
if (new Date().getTime() - lastTimeBackPress < timePeriodToExit) {
platform.exitApp(); //Exit from app
} else {
this.common.presentToast("Press back again to exit App?", "bottom");
lastTimeBackPress = new Date().getTime();
}
} else {
this.nav.pop({});
}
});
In my application there is two section SignIn and Hometabs. Above code work fine on the SignIn page.
if (view.component.name == 'SignInPage' )
But I try "HometabsPage" instead of "SignInPage" after that in all pages show the toast message.
Please help me.