public final class PushMessage

  1. Object
  2. PushMessage

Immutable typed push message used by clients and sending code.

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

Nested types

class PushMessage.BuilderBuilds an immutable PushMessage.

Fields

public static final int SCHEMA_VERSION = 3Current JSON envelope schema.

Methods

public static PushMessage.Builder builder()Creates a message builder initialized with the current schema.
public static PushMessage parse(String json) throws IOExceptionParses a schema-3 JSON envelope.
public String getId()
public String getTitle()
public String getBody()
public String getImageUrl()
public String getDeepLink()
public String getCollapseKey()
public Map<String, Object> getData()
public Map<String, Object> getSurface()
public Map<String, Object> getPlatformOptions()
public Map<String, Object> toMap()
public String toJson()

Inherited methods

Field details

SCHEMA_VERSION

public static final int SCHEMA_VERSION = 3
Current JSON envelope schema.

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 String
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