Handle close ionic windows app by 'X' button

i want to show a confirmation when user clicks on ‘X’ button (as attached). Anyone has any idea for handling that?


A few questions:
How are you building this?
Are you using electron or something else?

Just create a simple ionic2 app, then build with ‘ionic run windows --arch=x64’. I want to handle "x’ button when user clicks to close the app.

Sorry i don’t know Electron.

So that is something that touches the native code of the app. You would need to have a cordova plugin that handles this, but I do not know of any.

You might have to research more on a plugin that would do what you’re asking

1 Like

Actually, I think he is talking about the small “x” in the input field. Right @datpt154?

Nope, i mean a “X” button to close the App (like browser close button)

That’s still not really that clear. Can you make a mock up or show an exact example with something pointing to what you’re wanting?

Sorry for that inconvenient.
I have just updated the Pic. Could you please take a look on new pic.

Ok, so you want to add a “confirm” dialog when someone tries to close the Windows App (container). I think this is part of the native wrapper, so you will probably have to change stuff in there. But I never worked with Windows.

(Ping @zoinky, @ncao, @A1development)

Okay yes, so this is something that will most likely need a native plugin to handle. I don’t know if there is a setting for this on the windows platform, it doesn’t really seem like a standard thing to have in the configuration (though that could be helpful)

Thanks all,

  • For browser we can do it with WindowEventHandlers.onbeforeunload.
  • For native app we can do it with “this.platform.registerBackButtonAction”

I have tried those 2 methods for windows, but that did not work. Hope someone find any solution ^.^

Nice! Could you share that code, maybe in a “demo” thread? I think some people would be quite interested in this!

" but that did not work"

I am not sure if he’s referring to all of it or just the close button