Class Share

java.lang.Object
org.vaadin.firitin.util.Share

public class Share extends Object
A simple wrapper for the Web Share API. Allows sharing text and URLs quickly via OS native share dialog, if the browser supports the Web Share (~ all but FF).

On Firefox (which does not support the Web Share API), it falls back to copying the text and URL to the clipboard and showing a notification on the screen.

See also: https://developer.mozilla.org/en-US/docs/Web/API/Web_Share_API

  • Constructor Details

    • Share

      public Share()
  • Method Details

    • setFirefoxFallbackNotification

      public static void setFirefoxFallbackNotification(Runnable firefoxFallbackNotification)
      Sets the action executed when the Web Share API is not supported (e.g. on Firefox). By default, it shows a notification that the URL has been copied to clipboard. Use e.g. to show a custom message.
      Parameters:
      firefoxFallbackNotification - the action to execute when the Web Share API is not supported.
    • share

      public static com.vaadin.flow.component.page.PendingJavaScriptResult share(String title, String text, URI url)
      Share a link using the Web Share API.
      Parameters:
      title - The title of the document being shared. May be ignored by the target.
      text - Arbitrary text that forms the body of the message being shared.
      url - A URL string referring to a resource being shared.
    • share

      public static com.vaadin.flow.component.page.PendingJavaScriptResult share(String title, String text, String url)
      Share a link using the Web Share API.
      Parameters:
      title - The title of the document being shared. May be ignored by the target.
      text - Arbitrary text that forms the body of the message being shared.
      url - A URL string referring to a resource being shared.
    • share

      public static com.vaadin.flow.component.page.PendingJavaScriptResult share(Share.ShareData data)