Handle close ionic windows app by 'X' button


#1

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

Thanks.


#2

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


#3

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.


#4

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


#5

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


#6

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


#7

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?


#8

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


#9

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)


#10

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)


#11

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 ^.^


#12

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


#13

" but that did not work"

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