In my ionic App, I used the double press back button(Hardware) to exit the app, in my Homepage.
constructor (public navCtrl: NavController,
public navParams: NavParams,
private platform: Platform,
............................
) {
this.platform.registerBackButtonAction(() => {
if (this.counter == 0) {
this.counter++;
this.pressAgainToast();
setTimeout(() => {
this.counter = 0
}, 3000)
} else {
// console.log("exitapp");
this.platform.exitApp();
}
}, 0);
}
when I open the app and press the back the button, it works properly. if I goto another page and back to home, and I tried back button, nothing happens.
in the another page i used like this
constructor(public navCtrl: NavController,
public navParams: NavParams,
private platform: Platform,
private view:ViewController) {
this.platform.registerBackButtonAction(() => {
this.navCtrl.pop()
});
}
How can I use it correctly? pls, help...