Package org.mozilla.geckoview
Class WebNotification
Object
org.mozilla.geckoview.WebNotification
- All Implemented Interfaces:
Parcelable
This class represents a single Web Notification. These
can be received by connecting a
WebNotificationDelegate to GeckoRuntime via
GeckoRuntime.setWebNotificationDelegate(WebNotificationDelegate).-
Nested Class Summary
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.ClassLoaderCreator<T extends Object>, Parcelable.Creator<T extends Object> -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal WebNotificationAction[]Array of actions available for this notification.static final Parcelable.Creator<WebNotification>Parcelable creator for WebNotification instances.final StringImageURL contains the URL of an icon to be displayed as part of the notification.final StringLang indicates the notification's language, as specified using a DOMString representing a BCP 47 language tag.final StringSimilar tosourcebut includes the full origin information, corresponding to `nsIPrincipal.origin`.final booleanindicates whether the notification came from private browsing mode or not.final booleanRequireInteraction indicates whether a notification should remain active until the user clicks or dismisses it, rather than closing automatically.final booleanWhen set, indicates that no sounds or vibrations should be made.final StringThis is the URL of the page or Service Worker that generated the notification.final StringTag is the ID of the notification, matching `nsIAlertNotification.name`.final StringText represents the body of the notification.final StringTextDirection indicates the direction that the language of the text is displayed.final StringTitle is shown at the top of the notification window.final int[]A vibration pattern to run with the display of the notification.Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE -
Method Summary
Modifier and TypeMethodDescriptionvoidclick()This should be called when the user taps or clicks a notification.voidThis should be called when the user taps or clicks a notification action.intvoiddismiss()This should be called when the app stops showing the notification.voidshow()This should be called when the app starts showing the notification.voidwriteToParcel(Parcel dest, int flags)
-
Field Details
-
title
Title is shown at the top of the notification window.- See Also:
-
tag
Tag is the ID of the notification, matching `nsIAlertNotification.name`. -
text
Text represents the body of the notification.- See Also:
-
imageUrl
ImageURL contains the URL of an icon to be displayed as part of the notification.- See Also:
-
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
Lang indicates the notification's language, as specified using a DOMString representing a BCP 47 language tag.- See Also:
-
requireInteraction
public final boolean requireInteractionRequireInteraction indicates whether a notification should remain active until the user clicks or dismisses it, rather than closing automatically.- See Also:
-
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 silentWhen set, indicates that no sounds or vibrations should be made.- See Also:
-
privateBrowsing
public final boolean privateBrowsingindicates whether the notification came from private browsing mode or not. -
vibrate
@NonNull public final int[] vibrateA 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:
-
actions
Array of actions available for this notification. -
origin
Similar tosourcebut includes the full origin information, corresponding to `nsIPrincipal.origin`. -
CREATOR
Parcelable creator for WebNotification instances.
-
-
Method Details
-
show
@UiThread public void show()This should be called when the app starts showing the notification. This is important, as it tells the result of the notification request to Web Content. -
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, seedismiss(). -
click
This should be called when the user taps or clicks a notification action. Note that this does not automatically dismiss the notification as far as Web Content is concerned. For that, seedismiss().- Parameters:
action- The action name if an action button is clicked, otherwise null.
-
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:
describeContentsin interfaceParcelable
-
writeToParcel
- Specified by:
writeToParcelin interfaceParcelable
-