|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavapns.notification.Payload
javapns.notification.PushNotificationPayload
public class PushNotificationPayload
A payload compatible with the Apple Push Notification Service.
| Constructor Summary | |
|---|---|
PushNotificationPayload()
Create a default payload with a blank "aps" dictionary. |
|
PushNotificationPayload(String rawJSON)
Construct a Payload object from a JSON-formatted string. |
|
PushNotificationPayload(String alert,
int badge,
String sound)
Create a payload and immediately add an alert message, a badge and a sound. |
|
| Method Summary | |
|---|---|
void |
addAlert(String alertMessage)
Add a simple alert message. |
void |
addBadge(int badge)
Add a badge. |
void |
addCategory(String category)
Add a category. |
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 |
addCustomAlertLaunchImage(String launchImage)
Create a custom alert (if none exist) and add a launch-image parameter. |
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. |
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. |
| Methods inherited from class javapns.notification.Payload |
|---|
addCustomDictionary, addCustomDictionary, addCustomDictionary, asSimulationOnly, estimatePayloadSizeAfterAdding, getCharacterEncoding, getExpiry, getPayload, getPayloadAsBytes, getPayloadSize, isEstimatedPayloadSizeAllowedAfterAdding, isPayloadSizeEstimatedWhenAdding, setCharacterEncoding, setExpiry, setPayloadSizeEstimatedWhenAdding, toString |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public PushNotificationPayload()
public PushNotificationPayload(String rawJSON)
throws JSONException
rawJSON - a JSON-formatted string (ex: {"aps":{"alert":"Hello World!"}} )
JSONException - thrown if a exception occurs while parsing the JSON string
public PushNotificationPayload(String alert,
int badge,
String sound)
throws JSONException
alert - the alert messagebadge - the badgesound - the name of the sound
JSONException| Method Detail |
|---|
public static PushNotificationPayload alert(String message)
message - the alert's message
public static PushNotificationPayload badge(int badge)
badge - the badge
public static PushNotificationPayload sound(String sound)
sound - the name of the sound
public static PushNotificationPayload combined(String message,
int badge,
String sound)
message - the alert messagebadge - the badgesound - the name of the sound
public static PushNotificationPayload test()
public static PushNotificationPayload complex()
public static PushNotificationPayload fromJSON(String rawJSON)
throws JSONException
rawJSON - a JSON-formatted string representing a payload (ex: {"aps":{"alert":"Hello World!"}} )
JSONException - if any exception occurs parsing the JSON string
public void addBadge(int badge)
throws JSONException
badge - a badge number
JSONException
public void addSound(String sound)
throws JSONException
sound - the name of a sound
JSONException
public void addAlert(String alertMessage)
throws JSONException
alertMessage - the alert's message
JSONException
public void addCategory(String category)
throws JSONException
alertMessage - the category
JSONException
public void addCustomAlertBody(String body)
throws JSONException
body - the body of the alert
JSONException - if the custom alert cannot be added because a simple alert already exists
public void addCustomAlertActionLocKey(String actionLocKey)
throws JSONException
actionLocKey - the title of the alert's right button, or null to remove the button
JSONException - if the custom alert cannot be added because a simple alert already exists
public void addCustomAlertLocKey(String locKey)
throws JSONException
locKey -
JSONException - if the custom alert cannot be added because a simple alert already exists
public void addCustomAlertLocArgs(List args)
throws JSONException
args -
JSONException - if the custom alert cannot be added because a simple alert already exists
public void addCustomAlertLaunchImage(String launchImage)
throws JSONException
launchImage -
JSONException - if the custom alert cannot be added because a simple alert already existspublic int getMaximumPayloadSize()
getMaximumPayloadSize in class Payload
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||