Device backbutton (platform.registerBackButtonAction) is not working for Application back button and it's not working for Device back button.
Can some one help me please?
How can I solve my problem?
code:-
ionViewDidLoad() {
this.navBar.backButtonClick = (e: UIEvent) => {
const alert = this.alertCtrl.create({
title: 'App termination',
message: 'Do you want to close the app?',
buttons: [{
text: 'Cancel',
role: 'cancel',
handler: () => {
console.log('Application exit prevented!');
}
}, {
text: 'Close App',
handler: () => {
this.platform.exitApp(); // Close this application
}
}]
});
alert.present();
}
}
Modify your app.component.ts file in following way,