public class PushBuilder

  1. Object
  2. PushBuilder
A convenience class for building a push notification Payload.

Constructors

public PushBuilder()

Methods

public PushBuilder title(String title)Sets the title of the push notification.
public PushBuilder badge(int badge)Sets the badge to set with the push notification.
public PushBuilder body(String body)Sets the body of the push notification.
public PushBuilder metaData(String metaData)Sets the metadata (i.e. content the user shouldn’t see) for the push notification.
public PushBuilder imageUrl(String imageUrl)Sets the URL for an image to send in the push notification.
public PushBuilder category(String category)Sets the category of the push notification.
public PushBuilder type(int type)Sets the type of the push notification.
public boolean isRichPush()A notification is considered to be a rich push notification if either #imageUrl or #category is set.
public int getType()Gets the type of the notification.
public String build()Builds the payload for this rich push notification.

Inherited methods

Constructor details

PushBuilder

public PushBuilder()

Method details

title

public PushBuilder title(String title)
Sets the title of the push notification.

Parameters

title String
The title of the push notification.

Returns

Self for chaining.

badge

public PushBuilder badge(int badge)
Sets the badge to set with the push notification.

Parameters

badge int
The badge to set.

Returns

Self for chaining.

body

public PushBuilder body(String body)
Sets the body of the push notification.

Parameters

body String
The body of the push notification.

Returns

Self for chaining.

metaData

public PushBuilder metaData(String metaData)
Sets the metadata (i.e. content the user shouldn’t see) for the push notification.

Parameters

metaData String
The metadata.

Returns

Self for chaining.

imageUrl

public PushBuilder imageUrl(String imageUrl)
Sets the URL for an image to send in the push notification. Make sure you use https:// or the image won’t be shown on iOS.

Parameters

imageUrl String
The image URL.

Returns

Self for chaining.

category

public PushBuilder category(String category)
Sets the category of the push notification.

Parameters

category String
The category.

Returns

Self for chaining.

type

public PushBuilder type(int type)

Sets the type of the push notification.

Types

TypeDescription 1Sends only body as the notification message 2Sends only metadata. Invisible to user but will be received in push callback 3Sends both metadata and body. Body is visible to the user. Push callback will receive <metadata>;<body>. 4Sends both title and body. Push callback will receive <title>;<body> 100Sends only the badge 101Sends the badge and body. Push callback will receive the body only. 102Sends the badge, title, and body. Push callback will receive <title>;<body>

Both #imageUrl and #category can be added to any notification type. If either of these values are non-null, then the push notification is considered to be a rich push notification, and #getType() will return 99, which signifies that it is a rich push notification.

Parameters

type int
The type of the push notification.

Returns

Self for chaining.

isRichPush

public boolean isRichPush()
A notification is considered to be a rich push notification if either #imageUrl or #category is set.

Returns

True if the notification is a rich notification.

getType

public int getType()
Gets the type of the notification. This will return 99 if #isRichPush() is true. Otherwise it will return the underlying type as set with #type(int).

Returns

The type of the notification.

build

public String build()
Builds the payload for this rich push notification.

Returns

The payload that can be passed as the message body to Push