I am developing a Windows 10 UWP App in javascript.
One of the requirement is to show a notification but only when the app is in background, not foreground.
My question is, what is the best way to check if the app is running in background/foreground, using javascript. Many thanks.
You use the same APIs you use from a Web page: Use document.hasFocus() to determine whether the app has focus. You will also receive the window.blur and window.focus events when you lose and regain focus.
what is the best way to check if the app is running in background/foreground, using javascript.
If you check the app lifecycle, you could use WebUIApplication.EnteredBackground Event and WebUIApplication.LeavingBackground Event to do judgement. For example, you could use ApplicationData.LocalSettings to store the states of current app. When the EnteredBackground or LeavingBackground event is fired, you could change this localsettings value in its event handler. Then, when you want to detect the app's states, you could get this localsettings value and do judgement.
Related
We all use Zoom or Webex to attend the meetings, then there is a popup that allows you to open the desktop app or you can continue on the web app. I want to implement a similar kind of user experience in my web application. But unable to understand how did they(zoom and Webex) did it.
I am not looking for a foolproof solution I just need to know the best approach to achieve it.
Update:
I am not doing it exactly like Zoom or Webex does. I have a button in my application so I am doing it onClick event.
In order to do this, you must register a protocol on your OS (ie. you can use protocol lib to register a specific one in an Electron app), this would allow your app to be called with simple URIs like myappprotocol://myappaction?myappparams
They make you install a client, that has caused many controversies since this is a gate for eventual security breaches
https://medium.com/bugbountywriteup/zoom-zero-day-4-million-webcams-maybe-an-rce-just-get-them-to-visit-your-website-ac75c83f4ef5
In my AngularJS application two windows communicate through localStorage in order to use a single websocket connection. The main window listens to messages from server putting incoming data into a localStorage property. The child window use an angular $watch on this property to put incoming data into a grid. The use of different windows and a single connection is a requirement.
The problem is that the controller of the child window seems not to be able to watch the localStorage property until the browser development tool (F12) is not open.
How can I fix this issue?
I have an angular project also using localstorage and localforage.js. This statement is really narrowing your problem to the development tools though, no?:
"until the browser development tool (F12) is not open."
Make sure this box is unchecked.
Reload the page and try again.
Or you might try this solution: Using localstorage checks in a different window using window.postMessage()
Our QA team reports several bugs stemming from having two windows open with localstorage, so the data access has to be tightly synchronized. So the child window would send data to the parent which would handle localstorage.
I wonder if it's possible to make a contoller for web music player. Some desktop players use hotkeys to pause/play so I don't need to open app and press pause. Can I somehow do this stuff with web player? My idea is to make a global hook and then do stuff. How can I do this?
Webapps run in a sandbox so you can't create global keyboard hooks. That requires native code (dlls, exes, etc). You can catch key events from the window object since javascript events usually bubble up to the parent but this would only be while your page is the active page.
A workaround would be to create the keyboard hook as native code & then talk to it via your web app. Say your keyboard hook dll could start a web server & your page could communicate via that web server. Or implement the hook in a browser addin that sends custom events to your web app.
On button click I want to go back to the last running app, just like the back button on android or Alt+Tab. Is there a way to do that?
There is no programmatic way to the last running app specifically. However, if you know what the app is, you can activate it using a protocol handler, if it has one. E.g. If you got activated because of some flow, and you know you want to return to AppB, and AppB supports a protocol, you can use the launcher API to launch: "Appb://foo", and that app will open.
Ok here is my problem, I've inherited an old ASP.NET 2 website which I've been asked to make iOS capable. My biggest headache so far is that because of the way you have to log into the system right now I need to pass the UserName to the iphone and also run the server Click event. I can do one or the other but not both, and hooking up to the username textbox via either the KeyUp event or the OnChanged event causes other problems with the Objective-C code for the iPhone.
Is there anyway that I can update both the phone and the server at basically the same time?