Class NotificationOptions

java.lang.Object
com.oorian.html.js.notification.NotificationOptions

public class NotificationOptions extends Object
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 Details

    • NotificationOptions

      public NotificationOptions()
      Creates default notification options.
  • Method Details

    • setIcon

      public NotificationOptions setIcon(String icon)
      Sets the notification icon URL.
      Parameters:
      icon - URL of the icon to display.
      Returns:
      This NotificationOptions instance for method chaining.
    • setBadge

      public NotificationOptions setBadge(String badge)
      Sets the badge icon URL (for mobile devices).
      Parameters:
      badge - URL of the badge icon.
      Returns:
      This NotificationOptions instance for method chaining.
    • setImage

      public NotificationOptions setImage(String image)
      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

      public NotificationOptions setTag(String tag)
      Sets the notification tag for grouping/replacing notifications.
      Parameters:
      tag - The tag string.
      Returns:
      This NotificationOptions instance for method chaining.
    • setRequireInteraction

      public NotificationOptions setRequireInteraction(boolean requireInteraction)
      Sets whether the notification requires user interaction to dismiss.
      Parameters:
      requireInteraction - True to require interaction.
      Returns:
      This NotificationOptions instance for method chaining.
    • setSilent

      public NotificationOptions setSilent(boolean silent)
      Sets whether the notification should be silent (no sound/vibration).
      Parameters:
      silent - True for silent notification.
      Returns:
      This NotificationOptions instance for method chaining.
    • setDir

      public NotificationOptions setDir(String dir)
      Sets the text direction.
      Parameters:
      dir - "auto", "ltr", or "rtl".
      Returns:
      This NotificationOptions instance for method chaining.
    • setLang

      public NotificationOptions setLang(String lang)
      Sets the language of the notification.
      Parameters:
      lang - The BCP 47 language tag.
      Returns:
      This NotificationOptions instance for method chaining.
    • toJavaScript

      public String toJavaScript()
      Converts these options to a JavaScript object literal.
      Returns:
      JavaScript object literal string.