How to properly use Hardware back button

I’m so desperately looking for an answer for this, please help.
I have three ionic pages, structure as follows

-features
 --home
 --request
   --new
   --old

And each pages has hardware back button listener inside the constructor function,
in new & old pages it simply change route back to home page,

this.platform.backButton.subscribeWithPriority(10, () => {
  this._router.navigate(['/features/home'])
});

in home.page.ts,

this.platform.backButton.subscribeWithPriority(10, () => {
  console.log(this.routerOutlet.canGoBack())
  if (!this.routerOutlet.canGoBack()) {
     App.exitApp()
  }
});

But my problem is when i put press back button on home page it doesn’t work but other two functions ( both new & old pages)working properly,

So then i put console.log inside every back button listener and once the app is on home page and once the back button is pressed it keeps calls the last visited page back button listener.

Any idea on what’s wrong here ?

1 Like