How to go back to the previous page with smartphone physical button - Ionic

0

How do I enable the physical button to perform a specific function on Ionic 3 ? (In this case, a function that makes the application open the homepage)

    
asked by anonymous 17.03.2018 / 09:52

1 answer

0

Good afternoon Teiji, you can use the Platform service, with it you can register the button action with a function, for example:

export class AnyPage{

  constructor(private navCtrl: NavController,
              private platform: Platform) {
    this.platform.registerBackButtonAction(() => {
      this.navCtrl.pop();
    });
  }
}

From that moment on, whenever you hit the physical button on the phone, it will execute this.navCtrl.pop() , but I do not know if using Native Transitions the NavController action will be useful.

    
04.05.2018 / 19:45