public class PushNotificationPayload extends Payload
| Constructor and Description |
|---|
PushNotificationPayload(String alert,
int badge,
String sound)
Create a payload and immediately add an alert message, a badge and a sound.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAlert(String alertMessage)
Add a simple alert message.
|
void |
addBadge(int badge)
Add a badge.
|
void |
addCustomAlertActionLocKey(String actionLocKey)
Create a custom alert (if none exist) and add a custom text for the right button of the popup.
|
void |
addCustomAlertBody(String body)
Create a custom alert (if none exist) and add a body to the custom alert.
|
void |
addCustomAlertLocArgs(List args)
Create a custom alert (if none exist) and add sub-parameters for the loc-key parameter.
|
void |
addCustomAlertLocKey(String locKey)
Create a custom alert (if none exist) and add a loc-key parameter.
|
void |
addSound(String sound)
Add a sound.
|
static PushNotificationPayload |
alert(String message)
Create a pre-defined payload with a simple alert message.
|
static PushNotificationPayload |
badge(int badge)
Create a pre-defined payload with a badge.
|
static PushNotificationPayload |
combined(String message,
int badge,
String sound)
Create a pre-defined payload with a simple alert message, a badge and a sound.
|
static PushNotificationPayload |
complex()
Create an empty payload which you can configure later.
|
static PushNotificationPayload |
fromJSON(String rawJSON)
Create a PushNotificationPayload object from a preformatted JSON payload.
|
int |
getMaximumPayloadSize()
Return the maximum payload size in bytes.
|
void |
setContentAvailable(boolean available)
Sets the content available.
|
static PushNotificationPayload |
sound(String sound)
Create a pre-defined payload with a sound name.
|
static PushNotificationPayload |
test()
Create a special payload with a useful debugging alert message.
|
addCustomDictionary, addCustomDictionary, addCustomDictionary, addCustomDictionary, asSimulationOnly, getCharacterEncoding, getExpiry, getPayload, getPayloadAsBytes, getPayloadSize, isEstimatedPayloadSizeAllowedAfterAdding, isPayloadSizeEstimatedWhenAdding, setCharacterEncoding, setPayloadSizeEstimatedWhenAdding, toStringpublic PushNotificationPayload(String alert, int badge, String sound) throws org.json.JSONException
alert - the alert messagebadge - the badgesound - the name of the soundorg.json.JSONExceptionpublic static PushNotificationPayload alert(String message)
message - the alert's messagepublic static PushNotificationPayload badge(int badge)
badge - the badgepublic static PushNotificationPayload sound(String sound)
sound - the name of the soundpublic static PushNotificationPayload combined(String message, int badge, String sound)
message - the alert messagebadge - the badgesound - the name of the soundpublic static PushNotificationPayload test()
public static PushNotificationPayload complex()
public static PushNotificationPayload fromJSON(String rawJSON) throws org.json.JSONException
rawJSON - a JSON-formatted string representing a payload (ex: {"aps":{"alert":"Hello World!"}} )org.json.JSONException - if any exception occurs parsing the JSON stringpublic void addBadge(int badge)
throws org.json.JSONException
badge - a badge numberorg.json.JSONExceptionpublic void addSound(String sound) throws org.json.JSONException
sound - the name of a soundorg.json.JSONExceptionpublic void addAlert(String alertMessage) throws org.json.JSONException
alertMessage - the alert's messageorg.json.JSONExceptionpublic void addCustomAlertBody(String body) throws org.json.JSONException
body - the body of the alertorg.json.JSONException - if the custom alert cannot be added because a simple alert already existspublic void addCustomAlertActionLocKey(String actionLocKey) throws org.json.JSONException
actionLocKey - the title of the alert's right button, or null to remove the buttonorg.json.JSONException - if the custom alert cannot be added because a simple alert already existspublic void addCustomAlertLocKey(String locKey) throws org.json.JSONException
locKey - org.json.JSONException - if the custom alert cannot be added because a simple alert already existspublic void addCustomAlertLocArgs(List args) throws org.json.JSONException
args - org.json.JSONException - if the custom alert cannot be added because a simple alert already existspublic void setContentAvailable(boolean available)
throws org.json.JSONException
available - org.json.JSONExceptionpublic int getMaximumPayloadSize()
Copyright © 2016. All rights reserved.