Javascript - Universal Windows App - Capture Close Event - javascript

Within my app I have a flag saying if data needs saving or not m_IsSaved.
If the user closes the app when m_IsSaved is false I need to give them a warning message and give them the option to return to the app without closing.
Ie, if they click YES the app closes normally. If they click NO then the app stays open and does not close. (This will then give them the option to save their data. The save function is already written and works fine.)
How is this done in javascript?

According to your description, it seems you want to prevent your UWP app from closing when m_IsSaved is false. However, this is not possible. For UWP apps, we can't prevent the app from suspending or closing.
Refer App close:
There is not an event to indicate that the user closed the app. When an app is closed by the user, it is first suspended to give you an opportunity to save its state.
So you can always save the data with Application.Suspending event (for WinJS app, it would be WinJS.Application.oncheckpoint event). I think there is no need to prevent users from closing your app.
For more info, please see Windows 10 universal Windows platform (UWP) app lifecycle.

Related

How do I prompt user to enable pop up in any browser with React.js?

I am using "#azure/msal-browser": "^2.1.0", with my React SPA that is hosted on Azure app service. In my App.js I am using msalInstance.acquireTokenPopup(tokenRequest) to get a auth token, and this triggers a pop in the browser to prompt user to login if they are not. I need to check if browser is allowing popup if not, ask user to enable it first and reload the app. Would be a great help if anyone has a good solution.
If the token request is triggered by a user-generated event handler - onclick() et al - it shouldn't make a difference that the browser is running a pop-up blocker.
Popups exist from really ancient times...
You could also use .acquireTokenRedirect() instead of .acquireTokenPopup()

PWA Chrome cancel window.close() without alert message or default message

Hello we have a question about PWA and window.close events,
Before asking the question we will give some background information why we are asking this question in the first place.
We are trying to rebuild our XUL appllication to a HTML5 one with webcomponents and PWA. In this XUL Application there are allot of pop-ups with there own child windows,the user shouldn't be able to close a parent window while still having edited data inside a child window. This problem is solved when using the beforeunload event on the window object. One small problem you can't really customize this events behavior the user just gets the default message of data loss.The custom message behavior isn't available anymore because the behavior is obsolete since chrome 51.
So far the background of the problem we are trying to solve.
The question,
isn't there any setting inside the PWA manifest.json so you could ask user permission settings to be changed when the PWA is installed and run for the first time. And when this happens the user will be asked to give permission for the window.close event to be cancel-able. When doing this the user confirms to custom or none beforeunload alert pop-ups. This behavior will only be activated if the PWA is installed to the desktop of the user.
Hopefully this is or will be a option.
No, there is no permissions definition in webapp manifest.
(there is something similar for chrome extensions though)
By definition a PWA should behave as a native application, so if you are rewriting software to be a PWA you should re-model your application logic so that it stores the last state of the application on localStorage/indexedDB or similar and reads it upon starting and this would enforce the user to stay on the state you need it. No one should enforce the user to stay with the application open when they don't want.

OfficeJS Excel 2013 - Login flow in IE protected mode

I just want to see if anyone ran into the following scenario where we are facing couple of issues.
scenario:-
User clicks a button with in addin webapp, popup opens up with a predefined login flow, once login is completed, token returns back to addin webapp and remaining application flow continues.
Couple of issues we are facing are ...
If we dont set/use IE in protected mode, the app doesn't seem to return the control back to the addin. Without token, we can't let the user continue.
So if we use IE in protected mode, we are facing issues like
1. the web UI app calls with excel API doesn't seem to work properly. Especially, binding and events.
2. The internal calls from web UI to rest services doesnt work properly.
Just wondering if you guys have any input.
If you are using window.open directly to create a pop-up then the behavior you described is expected; that is how IE behaves with different integrity level (which is essentially what happens when 2 sites are in different security zones).
If you are using the Dialog API to create a dialog, for rich clients, like Excel for Windows Desktop, then you should not experience this issue as the process that we create is on the same integrity level as the parent (usually a taskpane). So give that a go.

How to check using jsp whether an app is installed in mobile or not?

I am working on a mobile website. We are showing a default screen on mobile website with 2 options.
1. Open in app
2. Continue to mobile site
now I have to check when user chooses Open in App, if App is already installed on mobile, open App.
If not go to play store.
Right now it is going to play store anyway.
How can I verify this, please suggest.
You can register an intent filter for a specific URI in the manifest. Whenever the URI is resolved by the system (for example when you click on it in the browser) you application would be notified and could start up. See also this so entry. But that does not handle the automatic redirect to the play store if the app is not installed. Maybe deep linking could do the job for you. This talk may also be relevant for deep linking.

Unable to listen to default close button of a Dsektop window

I am developing a windows desktop application using node.js and backbone.js. I want to perform an action when the user closes the app by clicking on the close button on the title bar or right clicking on the application from windows taskbar.
Please help.
It depends on what node-desktop technology are you using- if you are using node-webkit, then this comment on this pull request gives some indication of how to use the API bindings for the windowing system to do something like this.

Categories