We are working on tutorials and on adding basic PWA support to our starters. In the meantime, you can register a ServiceWorker through JavaScript. The contents of the ServieWorker itself are not dependent on Vaadin, so you can for instance look at this Google tutorial for adding Push message support: https://developers.google.com/web/fundamentals/codelabs/push-notifications/
Please bear in mind to only trigger the push notification prompt when a user expects it - for instance when they click on a “subscribe to notifications” button in the UI. Showing the prompt immediately on page load can easily lead to poor conversions and unhappy users.
Hi Marcus, what is the current state of PWA Push Notifications support in Vaadin? The documentation doesn’t mention anything which leads me to believe it’s basically “do it yourself”.
However, if it’s really a “do it yourself”, is it even possible to achieve? Vaadin will register its own service worker when @PWA is used, which is pretty much a static script. Right, but you can modify the script according to this tutorial: https://vaadin.com/docs/flow/pwa/tutorial-pwa-service-worker.html .
So the only solution is to introduce my own sw.js script which listens for push notifications and notifies the rest of the client-side about them.
Currently the best way to do it would be to copy the autogenerated sw.js, add your own push handling there and then use a library like https://github.com/web-push-libs/webpush-java on the server to do the actual push.