Hardware back button didnt work

app.component.ts

platform.registerBackButtonAction(function (event) {
    let confirm = this.alertCtrl.create({
      title: 'EXİT?',
      message: 'Do you agree exit?',
      buttons: [
        {
          text: 'No',
          handler: () => {
            console.log('Disagree clicked');
          }
        },
        {
          text: 'Yes',
          handler: () => {
            console.log('Agree clicked');
            this.platform.exitApp();
          }
        }
      ]
    });
    confirm.present();
    });

But it didnt work

Did you put it inside your platform.ready()?