Push and local notifications add-on

Hi all!
I just started working on an add-on that allows using browser Notification API from the server side, both for local (e.g. while the app is running in the browser) and push (via Service Workerks) notifications.

Why would you want to use (push) notifications in your Vaadin application? Let’s say that your application does some long, long processing, in the order of tens of minutes. In that case you don’t want to block the UI. Instead you want to do the processing in the background (maybe even on a different machine) and when it’s done let the user know that the wait is over and maybe even give them an option to go to the results of processing, decide what to do next etc. You could for example send an email. Or you could also push a notification. With push notification your app doesn’t even need to be open in the browser. On a mobile device you will get a notification that will look the same as notification from a native mobile app.

Currently the add-on only allows querying for support of the API in the browser and checking whether user allowed displaying notifications from the origin of the application.
The roadmap is following:

  1. Add a method to actually ask user for permission to display notifications
  2. Add an API to display local notifications
  3. Add a method to subscribe the user to push notifications via W3 standard API (https://w3c.github.io/push-api/)
  4. (Huge maybe) Implement Java API to send push messages (from your application server). Consider using https://github.com/web-push-libs/webpush-java
  5. Implement Safari’s push notifications
  6. (Huge maybe) Implement Java API to send push messages to Safari users.

The add-on is available from the Directory: https://vaadin.com/directory/component/browser-notifications-for-flow

Hello Mac,
I like the idea of your add-on. You ought to consider that Apple hasn’t implemented the push api on iOS (current version iOS 11.4).
https://caniuse.com/#search=push%20api
So you can’t receive push notifications on iOS-Safari yet. Hopefully this will come in future!

Hi Dennis, thank you for your feedback. You’re correct that there are no push notifications on iOS Safari, but there are on desktop Safari. It also seems like the feature might land in iOS in the future :slight_smile:

Hey Mac, were you able to finish this add-on? It’s a great idea and there exists no similar add-on yet for flow.

Hi Kaspar

I havent’t finished this add-on yet, but neither have I given up on it. I hope to finalize some more features in the following weeks.

Hi Max,
in how far is the api usable so far? I tried you example, but failed in notify all users that are logged in.