I am facing problem with the hardware back button on android. I am working with Ionic CLI 4.12.0 I want to exit the app when user on homePage and clicks back button. But back button event is not firing up. It navigate to login page then restarts the app. I am using Tabs template in my app. I have tried many answers of stackoverflow that claims solution to the similar problem. I have setup code in app component as following:
@ViewChild(IonRouterOutlet) routerOutlet: IonRouterOutlet;
constructor(private platform: Platform){
this.platform.backButton.subscribeWithPriority(0, () => {
console.log("back button clicked");
navigator["app"].exitApp();
})
}
Finally I found the answer of my question:
ionViewDidEnter() {
document.addEventListener("backbutton",function(e) {
console.log("disable back button called from tab 1")
}, false);
}