The code is as follow
constructor(public platform: Platform,public alertCtrl:AlertController) {
platform.ready().then(() => {
platform.registerBackButtonAction(()=>this.myHandlerFunction())
StatusBar.styleDefault();
Splashscreen.hide();
});
}
myHandlerFunction(){
let alert = this.alertCtrl.create({
title: 'Exit?',
message: 'Do you want to exit the app?',
buttons: [
{
text: 'Cancel',
role: 'cancel',
handler: () => {
}
},
{
text: 'Exit',
handler: () => {
this.platform.exitApp();
}
}
]
});
alert.present();
}
I need the myHandlerFunction() to be called on the Homepage only