Package com.vaadin.flow.component.webnotification
Use
WebNotification.onClick(component) to ask for permission when a component is
clicked,
WebNotification.permissionSignal()
to observe whether notifications are allowed, and
WebNotification.show(String)
to show a notification.
Permission is requested through onClick rather than an ordinary
server-side click listener because browsers only show the permission prompt
while handling a genuine user gesture, which is no longer valid by the time a
server round trip completes. Showing a notification once permission is
granted needs no gesture and works from any server-side code, including
background threads through UI.access.
This is not the same as com.vaadin.flow.component.notification
.Notification, which shows a toast inside the page, nor as Web Push, which
delivers messages through a service worker when the application is not open.
-
ClassDescriptionEntry point for the browser's Notifications API, which shows native operating system notifications while the application is open in a browser tab.What web notifications ask of their client-side bridge, as a JavaScript definition for
Element.executeJs(Class).Fluent surface returned fromWebNotification.onClick(com.vaadin.flow.component.Component), used to ask for permission to show notifications when a component is clicked.Why the browser did not show a notification.What kind of failure prevented a notification from being shown.A notification shown withWebNotification.show(java.lang.String).What a notification shows besides its title, and how it behaves.BuildsWebNotificationOptions.Whether the browser lets the application show notifications.