public final class PayloadBuilder extends Object
Modifier and Type | Method and Description |
---|---|
PayloadBuilder |
actionKey(String actionKey)
Sets the value of action button (the right button to be
displayed).
|
PayloadBuilder |
alertAction(String action)
Sets the alert action text
|
PayloadBuilder |
alertBody(String alert)
Sets the alert body text, the text the appears to the user,
to the passed value
|
PayloadBuilder |
alertTitle(String title)
Sets the alert title text, the text the appears to the user,
to the passed value.
|
PayloadBuilder |
badge(int badge)
Sets the notification badge to be displayed next to the
application icon.
|
String |
build()
Returns the JSON String representation of the payload
according to Apple APNS specification
|
byte[] |
buildBytes()
Returns the bytes representation of the payload according to
Apple APNS specification
|
PayloadBuilder |
category(String category)
Sets the category of the notification for iOS8 notification
actions.
|
PayloadBuilder |
clearBadge()
Requests clearing of the badge number next to the application
icon.
|
PayloadBuilder |
copy()
Returns a copy of this builder
|
PayloadBuilder |
customField(String key,
Object value)
Sets any application-specific custom fields.
|
PayloadBuilder |
customFields(Map<String,?> values)
Set any application-specific custom fields.
|
PayloadBuilder |
forNewsstand()
Sets the notification type to be a 'newstand' notification.
|
PayloadBuilder |
instantDeliveryOrSilentNotification()
With iOS7 it is possible to have the application wake up before the user opens the app.
|
boolean |
isTooLong()
Returns true if the payload built so far is larger than
the size permitted by Apple (which is 2048 bytes).
|
PayloadBuilder |
launchImage(String launchImage)
Sets the launch image file for the push notification
|
int |
length()
Returns the length of payload bytes once marshaled to bytes
|
PayloadBuilder |
localizedArguments(Collection<String> arguments)
Sets the arguments for the alert message localizable message.
|
PayloadBuilder |
localizedArguments(String... arguments)
Sets the arguments for the alert message localizable message.
|
PayloadBuilder |
localizedKey(String key)
Set the notification localized key for the alert body
message.
|
PayloadBuilder |
localizedTitleArguments(Collection<String> arguments)
Sets the arguments for the localizable title key.
|
PayloadBuilder |
localizedTitleArguments(String... arguments)
Sets the arguments for the localizable title key.
|
PayloadBuilder |
localizedTitleKey(String key)
The key to a title string in the Localizable.strings file for the current localization.
|
PayloadBuilder |
mdm(String s) |
static PayloadBuilder |
newPayload() |
PayloadBuilder |
noActionButton()
Set the notification view to display an action button.
|
PayloadBuilder |
resizeAlertBody(int payloadLength)
Shrinks the alert message body so that the resulting payload
message fits within the passed expected payload length.
|
PayloadBuilder |
resizeAlertBody(int payloadLength,
String postfix)
Shrinks the alert message body so that the resulting payload
message fits within the passed expected payload length.
|
PayloadBuilder |
shrinkBody()
Shrinks the alert message body so that the resulting payload
message fits within require Apple specification (2048 bytes).
|
PayloadBuilder |
shrinkBody(String postfix)
Shrinks the alert message body so that the resulting payload
message fits within require Apple specification (2048 bytes).
|
PayloadBuilder |
sound(String sound)
Sets the alert sound to be played.
|
String |
toString() |
PayloadBuilder |
urlArgs(String... urlArgs)
Sets the "url-args" key that are paired with the placeholders
inside the urlFormatString value of your website.json file.
|
public PayloadBuilder alertBody(String alert)
alert
- the text to appear to the userpublic PayloadBuilder alertTitle(String title)
title
- the text to appear to the userpublic PayloadBuilder localizedTitleKey(String key)
key
- the localizable message title keypublic PayloadBuilder localizedTitleArguments(Collection<String> arguments)
arguments
- the arguments to the localized alert messagepublic PayloadBuilder localizedTitleArguments(String... arguments)
arguments
- the arguments to the localized alert messagepublic PayloadBuilder alertAction(String action)
action
- The label of the action buttonpublic PayloadBuilder urlArgs(String... urlArgs)
urlArgs
- the values to be paired with the placeholders inside
the urlFormatString value of your website.json file.public PayloadBuilder sound(String sound)
null
disables the notification sound.sound
- the file name or song name to be played
when receiving the notificationpublic PayloadBuilder category(String category)
null
removes the category.category
- the name of the category supplied to the app
when receiving the notificationpublic PayloadBuilder badge(int badge)
badge
- the badge number to be displayedpublic PayloadBuilder clearBadge()
badge(0)
.public PayloadBuilder actionKey(String actionKey)
null
actionKey indicates no additional button
is displayed, just the Cancel button.actionKey
- the title of the additional buttonpublic PayloadBuilder noActionButton()
actionKey(null)
public PayloadBuilder forNewsstand()
public PayloadBuilder instantDeliveryOrSilentNotification()
public PayloadBuilder localizedKey(String key)
key
- the localizable message body keypublic PayloadBuilder localizedArguments(Collection<String> arguments)
arguments
- the arguments to the localized alert messagepublic PayloadBuilder localizedArguments(String... arguments)
arguments
- the arguments to the localized alert messagepublic PayloadBuilder launchImage(String launchImage)
launchImage
- the filename of the image file in the
application bundle.public PayloadBuilder customField(String key, Object value)
key
- the custom field namevalue
- the custom field valuepublic PayloadBuilder mdm(String s)
public PayloadBuilder customFields(Map<String,?> values)
values
- the custom mappublic int length()
public boolean isTooLong()
public PayloadBuilder resizeAlertBody(int payloadLength)
payloadLength
- the expected max size of the payloadpublic PayloadBuilder resizeAlertBody(int payloadLength, String postfix)
payloadLength
- the expected max size of the payloadpostfix
- for the truncated body, e.g. "..."public PayloadBuilder shrinkBody()
public PayloadBuilder shrinkBody(String postfix)
postfix
- for the truncated body, e.g. "..."public String build()
public byte[] buildBytes()
public PayloadBuilder copy()
public static PayloadBuilder newPayload()
Copyright © 2015. All rights reserved.