Class WebNotification

Object
org.mozilla.geckoview.WebNotification
All Implemented Interfaces:
Parcelable

public class WebNotification extends Object implements Parcelable
This class represents a single Web Notification. These can be received by connecting a WebNotificationDelegate to GeckoRuntime via GeckoRuntime.setWebNotificationDelegate(WebNotificationDelegate).
  • Field Details

    • title

      @Nullable public final String title
      Title is shown at the top of the notification window.
      See Also:
    • tag

      @NonNull public final String tag
      Tag is the ID of the notification.
      See Also:
    • text

      @Nullable public final String text
      Text represents the body of the notification.
      See Also:
    • imageUrl

      @Nullable public final String imageUrl
      ImageURL contains the URL of an icon to be displayed as part of the notification.
      See Also:
    • textDirection

      @Nullable public final String textDirection
      TextDirection indicates the direction that the language of the text is displayed. Possible values are: auto: adopts the browser's language setting behaviour (the default.) ltr: left to right. rtl: right to left.
      See Also:
    • lang

      @Nullable public final String lang
      Lang indicates the notification's language, as specified using a DOMString representing a BCP 47 language tag.
      See Also:
    • requireInteraction

      @NonNull public final boolean requireInteraction
      RequireInteraction indicates whether a notification should remain active until the user clicks or dismisses it, rather than closing automatically.
      See Also:
    • source

      @Nullable public final String source
      This is the URL of the page or Service Worker that generated the notification. Null if this notification was not generated by a Web Page (e.g. from an Extension).

      TODO: make NonNull once we have Bug 1589693

    • silent

      public final boolean silent
      When set, indicates that no sounds or vibrations should be made.
      See Also:
    • vibrate

      @NonNull public final int[] vibrate
      A vibration pattern to run with the display of the notification. A vibration pattern can be an array with as few as one member. The values are times in milliseconds where the even indices (0, 2, 4, etc.) indicate how long to vibrate and the odd indices indicate how long to pause. For example, [300, 100, 400] would vibrate 300ms, pause 100ms, then vibrate 400ms.
      See Also:
    • CREATOR

      public static final Parcelable.Creator<WebNotification> CREATOR
  • Method Details

    • click

      @UiThread public void click()
      This should be called when the user taps or clicks a notification. Note that this does not automatically dismiss the notification as far as Web Content is concerned. For that, see dismiss().
    • dismiss

      @UiThread public void dismiss()
      This should be called when the app stops showing the notification. This is important, as there may be a limit to the number of active notifications each site can display.
    • describeContents

      public int describeContents()
      Specified by:
      describeContents in interface Parcelable
    • writeToParcel

      public void writeToParcel(Parcel dest, int flags)
      Specified by:
      writeToParcel in interface Parcelable