How to prevent hardware backbutton while using ModalController

I am currently using ionic latest version 4.11.5

I used loading controller for loading the pages but when back button is pressed the app navigates backward while the loader is still active i cant find a way to disable hardware back button in loading controller so i switched to modal controller for loader yet i can’t find a way to disable hardware back button any advice!?

I think it must work if you subscribe to the backButton from platform in the modal:

this.platform.backbutton.subscribeWithPriority(1, () => {
});

and do nothing. Remember to unsubscribe when Page becomes destoryed.

3 Likes

yup it will work but unfortunately then the back button doesn’t work anywhere else

That’s not correct. If you subscribe to this on the Modals Page OnInit and unsubscribe on the Modals Page OnDestroy, it will work everywhere expect on this page

2 Likes

it worked weather the same stuff is applicable for loading controller @EinfachHans