Skip to content

Commit

Permalink
Updates for payload max size (now 2048) and category
Browse files Browse the repository at this point in the history
  • Loading branch information
sypecom committed Sep 30, 2014
1 parent 4e53074 commit d121d47
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/javapns/notification/PushNotificationPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
public class PushNotificationPayload extends Payload {

/* Maximum total length (serialized) of a payload */
private static final int MAXIMUM_PAYLOAD_LENGTH = 256;
private static final int MAXIMUM_PAYLOAD_LENGTH = 2048;

@Deprecated
private static final int MAXIMUM_PAYLOAD_LENGTH_LEGACY = 256;


/**
Expand Down Expand Up @@ -221,6 +224,19 @@ public void addAlert(String alertMessage) throws JSONException {
}


/**
* Add a category.
*
* @param alertMessage the category
* @throws JSONException
*/
public void addCategory(String category) throws JSONException {
String previousCategory = getCompatibleProperty("category", String.class, "A custom category (\"%s\") was already added to this payload");
logger.debug("Adding category [" + category + "]" + (previousCategory != null ? " replacing previous category [" + previousCategory + "]" : ""));
put("category", category, this.apsDictionary, false);
}


/**
* Get the custom alert object, creating it if it does not yet exist.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Specific exception indicating that a payload exceeds the maximum size allowed.
*
* The maximum size allowed for PushNotification objects is the actual number
* explicitely documented in Apple's APNS specifications (256 bytes).
* explicitely documented in Apple's APNS specifications.
*
* You do not need to catch this exception specifically, as it will be put in a
* PushedNotification object as the exception that caused a push notification to having failed.
Expand Down

0 comments on commit d121d47

Please sign in to comment.