Hardware back button with Ionic 4 Disable

#1

Hi everyone,
How do I disable the hardware back button in android? I’ll explain. I would like the click to always remain on the same page it’s possible?
thanks

#2

Have you tried this change in the app,module.ts?

IonicModule.forRoot({hardwareBackButton: false})
#3

Maybe something like

const sub = this.platform.backButton.subscribeWithPriority(9999, () => {
  // Do nothing
});
1 Like
#4

hi yes i’ve try but not work :frowning:

#5

I’ve try your solution but not work, the event not fire

#6

I am looking for how to do so only the back button material shipments on a specific page without taking into account the battery

#7

finally I’ve found a solution, this work!!!

ionViewDidEnter() {
    document.addEventListener("backbutton",function(e) {
      console.log("disable back button")
    }, false);
}
2 Likes
#8

For me this did work, but is there a way to restore the default functionality after using this?

#9

I guess unsubsribe no?

if (sub) {
   sub.unsubscribe();
}
2 Likes
#10

This is not working.

There is an openen issue on github: