Find out if alert over active view


With that code, you close any overlay (alert, popover, modal), any page if there is a previous page.and move the app in background if there is no previous page :

  constructor(public platform: Platform, public app: App) {

      platform.registerBackButtonAction(() => {
        let nav = app._appRoot._getActivePortal() || app.getActiveNav();
        let activeView = nav.getActive();

        if (activeView != null) {
          if (nav.canGoBack()) {
          } else if(activeView.isOverlay) {
          } else {

I do not use that code in production for the moment but I tested it with an Alert, modal page and popover and that did the job but I still have to test it with a loader (I fear it closes the loader even if you do not want to) and I will have to find a trick for that.

So check if it works for you and feel free to improve and share the code :slight_smile: