Skip to content

Commit

Permalink
When setting the content-available flag, don't remove the user visibl…
Browse files Browse the repository at this point in the history
…e fields such as badge, sound, and alert. Closes #27
  • Loading branch information
judepereira committed Dec 18, 2017
1 parent 427daf4 commit 16e6716
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/main/java/com/clevertap/apns/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ public int getCode() {

/**
* Constructs a new Notification with a payload and token.
*
* @param payload The JSON body (which is used for the request)
* @param token The device token
* @param topic The topic for this notification
* @param collapseId The collapse ID
* @param expiration A UNIX epoch date expressed in seconds (UTC)
* @param priority The priority of the notification (10 or 5)
* @param uuid A canonical UUID that identifies the notification
* @param priority The priority of the notification (10 or 5)
* @param uuid A canonical UUID that identifies the notification
*/
protected Notification(String payload, String token, String topic, String collapseId, long expiration, Priority priority, UUID uuid) {
this.payload = payload;
Expand Down Expand Up @@ -144,7 +145,6 @@ public static class Builder {
private final String token;
private String topic = null;
private String collapseId = null;
private boolean contentAvailable = false;
private long expiration = -1; // defaults to -1, as 0 is a valid value (included only if greater than -1)
private Priority priority;
private UUID uuid;
Expand Down Expand Up @@ -182,7 +182,6 @@ public Builder contentAvailable(boolean contentAvailable) {
aps.remove("content-available");
}

this.contentAvailable = contentAvailable;
return this;
}

Expand Down Expand Up @@ -272,13 +271,6 @@ public Notification build() {
root.put("aps", aps);
aps.put("alert", alert);

// Clean up the aps dictionary for content-available notifications
if (contentAvailable) {
aps.remove("alert");
aps.remove("sound");
aps.remove("badge");
}

final String payload;
try {
payload = mapper.writeValueAsString(root);
Expand Down

0 comments on commit 16e6716

Please sign in to comment.