Interface IPushNotificationMessageBuilder

All Known Implementing Classes:
PushMessageBuilder

public interface IPushNotificationMessageBuilder
A fluent builder for constructing a IPushNotification.

The builder is the sole way to create a notification. It is chainable — each setter returns this — and validates on build(), which produces an immutable notification and after which the builder should not be reused. A minimal notification requires only a title; everything else has a default (an empty options map, and the server-default TTL).

Obtain one from the engine, e.g. getPushNotificationEngine().newMessageBuilder(), so the builder is bound to the engine's settings for defaults such as TTL.

Example:

    IPushNotification n = engine.newMessageBuilder()
        .title("New message")
        .body("You have 3 unread messages")
        .icon("/icons/app-192.png")
        .tag("inbox")
        .data("threadId", "T-4417")
        .timeToLive(3_600_000L)   // one hour, in ms
        .build();

Author:
IIZI
  • Method Details

    • title

      Sets the notification title (the showNotification title argument). Required.
      Parameters:
      title - The title; must be non-null and non-empty.
      Returns:
      this, for chaining.
    • body

      Sets the notification body (the options.body field) — the secondary text shown beneath the title.
      Parameters:
      body - The body text.
      Returns:
      this, for chaining.
    • icon

      Sets the notification icon URL (the options.icon field).
      Parameters:
      iconUrl - The icon URL.
      Returns:
      this, for chaining.
    • badge

      Sets the notification badge URL (the options.badge field) — the monochrome glyph a device shows in its status area.
      Parameters:
      badgeUrl - The badge URL.
      Returns:
      this, for chaining.
    • tag

      Sets the notification tag (the options.tag field). Notifications sharing a tag coalesce on the device, replacing rather than stacking.
      Parameters:
      tag - The tag.
      Returns:
      this, for chaining.
    • data

      Adds one key/value pair to the notification's application data (the options.data object), which the service worker receives verbatim and the application interprets. Repeated calls accumulate; a repeated key overwrites.
      Parameters:
      key - The data key; must be non-null.
      value - The data value.
      Returns:
      this, for chaining.
    • option

      Sets an arbitrary option directly into the options map, for fields not covered by a dedicated setter (e.g. requireInteraction, silent, actions).
      Parameters:
      key - The option key; must be non-null.
      value - The option value.
      Returns:
      this, for chaining.
    • timeToLive

      IPushNotificationMessageBuilder timeToLive(long millis)
      Sets this notification's time-to-live in milliseconds, overriding the server default. Clamped by the engine to the configured TTL range; a notification left without an explicit TTL uses IPushSettings.getDefaultTTL().
      Parameters:
      millis - The TTL in milliseconds.
      Returns:
      this, for chaining.
    • build

      Validates the accumulated fields and builds the immutable notification.
      Returns:
      The built IPushNotification; never null.
      Throws:
      IllegalStateException - if a required field (the title) is missing or a field is invalid.