How can I hide notifications my site is displaying if it is focused and brought to the foreground? - web-push

Context: I am building a progressive web apps that sends my users push notifications with service worker.
Is there a way to ensure that if the user browses to my site while notifications are currently showing that the notifications are hidden?
I want to avoid the situation where they navigated to my site and the notifications are still displaying, now stale.

Yes, from the document you can clear all currently showing notifications like this:
// From a document.
navigator.serviceWorker.ready.then(registration => {
registration.getNotifications().then(notifications =>
notifications.forEach(notification => notification.close()));
});
You could choose to simply run this code every time a page loads to solve your case, or you could additionally add a focus event listener to the document that runs this code to ensure it is applied every time your site is brought into focus.

Related

Browser back button handling in Vue Js

On the application I am working on, the state of all items is saved in the backend API database. The Vue state has a boolean to let the user know when the state is dirty (synced with backend) or not. So the user can hit ctrl + s and save whenever they make changes.
An issue I have is that when a user hits refresh, they could lose their work. So I implemented a feature to open a dialog to alert the user they're about to lose their work if they hit f5 when the state is dirty. This was done with the "beforeUnload" event listener.
But I also need security for the users work when they hit the back button.
I can detect it with this code:
window.addEventListener("popstate ", (e) => {
});
But I can't figure out how to handle the event correctly and have the user cancel the pressing of the back button. Is this even possible?
Thanks.
This is not reliably possible in browsers, regardless of the framework you are using; see https://stackoverflow.com/a/12381610/5471218 for a similar question.
That said, I strongly advise against interfering with the user's browser interaction that way. If you want to protect users from losing data, you could save it to local storage until you have confirmation that the data has been stored in the backend.

How to track last login date for IBM Domino web user?

Does IBM Domino track the last login date for web users(UserName/Password and internet certificate)? I know the access logs contains this information but wanted to know if there may be something built into Domino (maybe in Address Book). Trying to come up with a method to disable web accounts that have not accessed a domino server in a specified time period.
Thanks,
Kev
The User Activity area in the Database Properties picks up from the log.nsf, which is where this information is stored. But, typically, the log.nsf will only have a few days' worth of information. When I've had this requirement before, I've manually captured it via a custom login page or an initUser function I've had in applications.
One of the easiest solutions is to trigger an action from a live web page that generates a database.nsf?openagent event.
like:
or
Ideally you've use the openagent to print a content type and a response, but if you don't browsers do pretty well with invalid responses from servers.
inside your "myagent" you will have the users name available to you to write it to a document.
Your next challenge will be in getting the agent to trigger, but, not too often, ideally only on login.
When a user uses a custom login form it submits the username/password and redirection url in POST method. You could change that to ...?openagent&nexturl=/blablabla.nsf
Your tiny little agent would run one and only one time upon login and update a document in a your custom logging database.
That's a developer's solution.
There are also admin solutions. The server does keep track of active web sessions, but, it does not drop them into the log.nsf like it does upon session ending for a notes session. I don't think it would be too much work from an admin standpoint to get that information there are a lot of event triggers available to you. It's just been way too long since I worked on any server that anyone cared about statistics.

Restrict user from closing outlook mail app, while some action is in progress

I am working on an Outlook mail app, which will be available to user on web only (not of outlook desktop).
A file need to be uploaded from app to azure via custom control in compose form of App, meanwhile the file is uploaded to Azure user should not be able to close the mail. If they try to do so, a warning should be given to them.
Adding to #Slava's answer, I would suggest using addAsync API for notification messages. You can add a notification of type progress indicator until your task is complete and replace it with a notification of type informational message.
Click here for reference
Unfortunately Office.js API does not have the feature you are inquiring. You will not be able to disallow user interaction, as such closing the compose window or closing your add-in. As the API doesn't have "OnSend" or "OnClose" events you will not be able to display any warning either. If this is the new feature you would like to add you may try to send request via Office Developers User Voice.
As the work around you should clearly indicate for the users that they need to wait and do not interup operation. You should display activity indicator, indeed. And finally you should be prepare user still interupt the operation in the middle and work properly with the error occur.
Hope this helps.

Using socket.io to send data to a specific view/id

I have a web application using NodeJS, Express, and MongoDB. In my application, I have a view, that can be seen by anyone who accesses the application. That view is rendered with a different image, depending on which a user selects to view (they do not need to be logged in) ie the view is mapView/mapId.
Now, I want something similar to notifications to occur in realtime for those that are on that page. When a specific event happens from an external source, I want to display a popup on the view to which the event belongs to. So the event may only belong to one mapView/mapId and not another mapView with a different ID. All users on the same mapView/mapId should see the notification. Remember, these are general users that do not need to be logged in.
I am researching into Socket.io because I know it is for making realtime applications. But I am wondering if this is even the right way to go. How will I send data to the correct mapView/mapId?
Check out what your server can do with rooms
The idea is that each of your connections, from a particular view, is joined to a room. Then you use socket.io from the server to send a message only to that room. And only those sockets will get the message.

Call server in background

I'm building an iPhone-app in which the logged in users can chat to each other. It's very like the Wordfeud chat for example. You click a user and a modal view controller shows up where you chat.
I have set up a push notification server that works, I just need to know just how I should use it.
When the chat view controller is open I poll in the background with ASIHttpRequest every tenth second to see if a message has been sent from the user you chat with. This works perfectly fine.
But what happends when i close the chat view controller to do something else in the app. Should I create a ASIHttpRequest in every single view controller in the app to poll for new messages or is it here the push notification service takes over? Even though the app is still open?
Or shouldn't I send push notifications when the app is running, only when it's not running?
If that's the case I guess I have to send a request to the server which says that the app is has now been closed (here is a problem if the app crashed out of the blue).
I would be really greatful for some guidelines here, I have searched the web but there are old discussions which confuses me, and some new ones where many people says different.

Resources