How to add confirmation popup on back button inside inAppBrowser in ionic

I have added an inAppBrowser and now after going inside the browser,

Expectation : if i click the hardware back button, i want to show a confirmation popup with option leave page and Cancel

Actual : It is calling the Exit event and closing the inAppBrowser

in my x.ts file :

this.inAppBrowser.on('exit').subscribe(
    () => {
      this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT);
      console.log('orientation after browser close: ' + this.screenOrientation.type);
    }
  );

My issue is that, do we have any way or workaround to detect backbutton click instead of exit ?



Read more here: https://stackoverflow.com/questions/68439059/how-to-add-confirmation-popup-on-back-button-inside-inappbrowser-in-ionic

Content Attribution

This content was originally published by Sourav Singh at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: