Ionic React Disable Hardware Back Button

Hi,

I have an issue with my Ionic React App. Whenever an ion modal is open and I use the android hardware back button (or window.history.back() on chrome), my modal becomes unresponsive. I believe that is due to the fact that the route has been switched but the modal is still displayed, so we’re not able to interact with the modal.

At this point, I’m just trying to disable the hardware back button for all devices, as it sounds like the most reasonable solution, but I’m having trouble with that.

I tried to setupIonicReact to not allow swiping:

setupIonicReact({
  swipeBackEnabled: false,
  hardwareBackButton: false
});

but that didn’t block the functionality. I tried to listen to the backButton event and that should have blocked the functionality, but still nothing:/

import { App as CapApp } from '@capacitor/app';

CapApp .addListener('backButton', (e) => {
    });

Does anyone know how I can accomplish disabling the hardware back button functionality using ionic react?

1 Like

Same here! Anyone help, Please