Ionic 4 Disable iOS Swipe Back in ONE PAGE ONLY

Hello everyone,

I want to disable iOS in one page only and not globally, so let’s say a user checkouts and makes the payment, i don’t want the user to go back to where he was after he gets the receipt. I want the user to stay to that page without the possibility to swipe back, in android i have already disabled the hardware button while in iOS i am struggling a bit.

i have added to app.module:

IonicModule.forRoot({ swipeBackEnabled: false })

which disables the swipe back globally and thats what i don’t want, i also tried this one:

Article about disabling swipe back

I followed it and still i could not reach what i want,

I also don’t get what the user says at the end:

The current implementation only works with a single IonRouterInstance in the application but it can be enhanced with support for additional instances if you require that in your own application.

What does he mean by WORKS WITH A SINGLE?

Thank you very much, any help would be appreciated.

private routerOutlet: IonRouterOutlet,

this.routerOutlet.swipeGesture = false;
try this in ngOnInit or ionViewWillEnter


that indeed works, thank you :), remember i also have to do TRUE when i leave page with ionViewWillLeave.

1 Like

In my case the solution above proposed was the solution to the problem but I had to avoid that the app left the home page to the login page when the user swiped back, to avoid this in ios I had to put this code in the navigation root (side menu or navigations tabs).

import { IonRouterOutlet } from '@ionic/angular';

  constructor( private routerOutlet: IonRouterOutlet) {}

 ngOnInit() {
    this.routerOutlet.swipeGesture = false;
1 Like