Jignesh M. Mehta
Jignesh M. Mehta

Reputation: 914

Confirmation alert before app close - Ionic2 using typescript

I make one application with IONIC-2 Beta version.I am trying to get alert before close the application.

In previous version of ionic 2 I used,

This Code

but in newer version this is not working.

How it is work with Type Script + ionic 2?

Upvotes: 1

Views: 496

Answers (1)

Vivek Sinha
Vivek Sinha

Reputation: 1596

You have to register hardwarebackbuttonaction in app.component.ts like this:

platform.registerBackButtonAction(() => {
    if(this.nav.canGoBack()){
        this.nav.pop();
    }else{
      if(isAlertShowing){
        //dismiss alert
      }else{
        //show alert
      }
    }
  });

Upvotes: 1

Related Questions