Package com.oorian.html.js.notification
Class NotificationOptions
java.lang.Object
com.oorian.html.js.notification.NotificationOptions
Configuration options for browser notifications.
Usage:
NotificationOptions options = new NotificationOptions()
.setIcon("/images/icon.png")
.setTag("message-123")
.setRequireInteraction(true);
NotificationApi.show(element, "New Message", options);
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the badge icon URL (for mobile devices).Sets the text direction.Sets the notification icon URL.Sets the notification image URL.Sets the language of the notification.setRequireInteraction(boolean requireInteraction) Sets whether the notification requires user interaction to dismiss.setSilent(boolean silent) Sets whether the notification should be silent (no sound/vibration).Sets the notification tag for grouping/replacing notifications.Converts these options to a JavaScript object literal.
-
Constructor Details
-
NotificationOptions
public NotificationOptions()Creates default notification options.
-
-
Method Details
-
setIcon
Sets the notification icon URL.- Parameters:
icon- URL of the icon to display.- Returns:
- This NotificationOptions instance for method chaining.
-
setBadge
Sets the badge icon URL (for mobile devices).- Parameters:
badge- URL of the badge icon.- Returns:
- This NotificationOptions instance for method chaining.
-
setImage
Sets the notification image URL.- Parameters:
image- URL of the image to display in the notification body.- Returns:
- This NotificationOptions instance for method chaining.
-
setTag
Sets the notification tag for grouping/replacing notifications.- Parameters:
tag- The tag string.- Returns:
- This NotificationOptions instance for method chaining.
-
setRequireInteraction
Sets whether the notification requires user interaction to dismiss.- Parameters:
requireInteraction- True to require interaction.- Returns:
- This NotificationOptions instance for method chaining.
-
setSilent
Sets whether the notification should be silent (no sound/vibration).- Parameters:
silent- True for silent notification.- Returns:
- This NotificationOptions instance for method chaining.
-
setDir
Sets the text direction.- Parameters:
dir- "auto", "ltr", or "rtl".- Returns:
- This NotificationOptions instance for method chaining.
-
setLang
Sets the language of the notification.- Parameters:
lang- The BCP 47 language tag.- Returns:
- This NotificationOptions instance for method chaining.
-
toJavaScript
Converts these options to a JavaScript object literal.- Returns:
- JavaScript object literal string.
-