Class WebNotificationBinding

java.lang.Object
com.vaadin.flow.component.webnotification.WebNotificationBinding
All Implemented Interfaces:
Serializable

public final class WebNotificationBinding extends Object implements Serializable
Fluent surface returned from WebNotification.onClick(com.vaadin.flow.component.Component), used to ask for permission to show notifications when a component is clicked. The request runs in the browser at click time, while the user gesture that browsers require for the permission prompt is still valid. Showing a notification needs no gesture, so it is done from the server with WebNotification.show(String).

 Button enable = new Button("Enable notifications");
 WebNotification.onClick(enable).requestPermission();
 
See Also:
  • Method Details

    • requestPermission

      public void requestPermission()
      Asks the user for permission to show notifications when the underlying trigger fires. The browser shows its permission prompt if the user has not decided yet, and does nothing if they already have.

      The answer arrives through WebNotification.permissionSignal(), so react to it there — for example by hiding the button once permission is WebNotificationPermission.GRANTED.