# Class PushMessage.Builder

java.lang.Object
com.codename1.push.PushMessage.Builder

Enclosing class:
  `PushMessage`

public static final class PushMessage.Builder extends Object
Builds an immutable `PushMessage`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `PushMessage.Builder`
  `body(String value)`
  `PushMessage`
  `build()`
  Creates an immutable message snapshot.
  `PushMessage.Builder`
  `collapseKey(String value)`
  `PushMessage.Builder`
  `data(String key, Object value)`
  Adds application data, or removes the key when value is null.
  `PushMessage.Builder`
  `deepLink(String value)`
  `PushMessage.Builder`
  `id(String value)`
  `PushMessage.Builder`
  `imageUrl(String value)`
  `PushMessage.Builder`
  `platform(String platformId, Map<String,Object> options)`
  Adds provider-specific options.
  `PushMessage.Builder`
  `silent(boolean value)`
  Selects data-only delivery when `true`.
  `PushMessage.Builder`
  `surface(Map<String,Object> command)`
  Sets a widget or live-surface command.
  `PushMessage.Builder`
  `title(String value)`
  `PushMessage.Builder`
  `ttlSeconds(int value)`
  Sets provider retention time.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### id

    public PushMessage.Builder id(String value)
    Parameters:
      `value` - message ID @return this builder

  - ### title

    public PushMessage.Builder title(String value)
    Parameters:
      `value` - visible title @return this builder

  - ### body

    public PushMessage.Builder body(String value)
    Parameters:
      `value` - visible body @return this builder

  - ### imageUrl

    public PushMessage.Builder imageUrl(String value)
    Parameters:
      `value` - HTTPS image URL @return this builder

  - ### deepLink

    public PushMessage.Builder deepLink(String value)
    Parameters:
      `value` - application deep link @return this builder

  - ### collapseKey

    public PushMessage.Builder collapseKey(String value)
    Parameters:
      `value` - provider collapse key @return this builder

  - ### ttlSeconds

    public PushMessage.Builder ttlSeconds(int value)
    Sets provider retention time.
    Parameters:
      `value` - positive lifetime in seconds
    Returns:
      this builder

  - ### silent

    public PushMessage.Builder silent(boolean value)
    Selects data-only delivery when `true`.
    Parameters:
      `value` - whether the message is silent
    Returns:
      this builder

  - ### data

    public PushMessage.Builder data(String key, Object value)
    Adds application data, or removes the key when value is null.
    Parameters:
      `key` - application-defined key
      `value` - JSON-compatible value
    Returns:
      this builder
    Throws:
      `IllegalArgumentException` - if key is null, empty, or has surrounding whitespace

  - ### platform

    public PushMessage.Builder platform(String platformId, Map<String,Object> options)
    Adds provider-specific options.
    Parameters:
      `platformId` - provider ID such as `fcm`, `apns`, `huawei`, `wns`, or `web`
      `options` - JSON-compatible options, or `null` to remove
    Returns:
      this builder
    Throws:
      `IllegalArgumentException` - if platformId is null, empty, or has surrounding whitespace

  - ### surface

    public PushMessage.Builder surface(Map<String,Object> command)
    Sets a widget or live-surface command.
    Parameters:
      `command` - command map, or `null` to remove it
    Returns:
      this builder

  - ### build

    public PushMessage build()
    Creates an immutable message snapshot. The builder may be reused.
    Returns:
      the message