Class PushMessage

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

public final class PushMessage extends Object

Immutable typed push message used by clients and sending code.

Common fields are provider-independent. Provider-specific options belong under PushMessage.Builder.platform(String, Map). Received JSON must contain a supported schema number and is exposed as immutable maps and lists.

  • Field Details

    • SCHEMA_VERSION

      public static final int SCHEMA_VERSION
      Current JSON envelope schema.
      See Also:
  • Method Details

    • builder

      public static PushMessage.Builder builder()
      Creates a message builder initialized with the current schema.
      Returns:
      a new builder
    • parse

      public static PushMessage parse(String json) throws IOException
      Parses a schema-3 JSON envelope.
      Parameters:
      json - complete JSON object
      Returns:
      an immutable message
      Throws:
      IOException - if JSON is empty, invalid, or has an unsupported schema
    • getId

      public String getId()
      Returns:
      the message identifier, or null
    • getTitle

      public String getTitle()
      Returns:
      the visible notification title, or null
    • getBody

      public String getBody()
      Returns:
      the visible notification body, or null
    • getImageUrl

      public String getImageUrl()
      Returns:
      the rich-notification image URL, or null
    • getDeepLink

      public String getDeepLink()
      Returns:
      the application deep link, or null
    • getCollapseKey

      public String getCollapseKey()
      Returns:
      the provider collapse key, or null
    • getData

      public Map<String,Object> getData()
      Returns:
      immutable application data, possibly empty
    • getSurface

      public Map<String,Object> getSurface()
      Returns:
      immutable widget or live-surface command data, possibly empty
    • getPlatformOptions

      public Map<String,Object> getPlatformOptions()
      Returns:
      immutable provider-specific options keyed by provider
    • toMap

      public Map<String,Object> toMap()
      Returns:
      the complete immutable envelope
    • toJson

      public String toJson()
      Returns:
      this message encoded as JSON