Skip to content
This repository was archived by the owner on Dec 6, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ leancloud-utils/.project
leancloud-utils/.settings
leancloud-utils/.classpath
/target/
*.iml
.idea
.idea/*


43 changes: 43 additions & 0 deletions src/main/java/com/avos/avoscloud/AVPush.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class AVPush {
private volatile AVObject notification;
private Date pushDate = null;
private boolean production = true;
private String reqId;
private String notificationId;

static {
AVPowerfulUtils.createSettings(AVPush.class.getSimpleName(), "push", "");
Expand Down Expand Up @@ -97,6 +99,14 @@ public Map<String, Object> getPushData() {
return pushData;
}

public String getReqId() {
return reqId;
}

public String getNotificationId() {
return notificationId;
}

/**
* Clears both expiration values, indicating that the notification should never expire.
*/
Expand Down Expand Up @@ -225,6 +235,14 @@ private Map<String, Object> postDataMap() throws AVException {
map.put("push_time", AVUtils.stringFromDate(pushDate));
}

if(this.reqId != null) {
map.put("req_id", reqId);
}

if(this.notificationId != null) {
map.put("notification_id", notificationId);
}

if (!production) {
map.put("prod", "dev");
}
Expand Down Expand Up @@ -493,4 +511,29 @@ public boolean getProductionMode() {
public void setProductionMode(boolean production) {
this.production = production;
}

/**
* Different push requests with the same req id in 5 minutes are considered duplicate requests and will
* only be sent once. User can use the unique req id in the request to retry the request when getting an
* exception such as timeout, to avoid missing messages. We will automatically filter the repeated push
* requests to ensure that each target end user will only receive push messages at most once.
*
* @param Custom request id, up to 16 characters and can only consist of English letters and numbers.
*/
public void setReqId(String reqId) {
this.reqId = reqId;
}

/**
* When this parameter is NOT provided, we will randomly assign a unique notification id for each push request to
* distinguish different pushes. We will use the notification id to count the number of push target devices and
* final message arrivals, and show them in the push record. The user-defined notification id can combine multiple
* different requests into the same notification id so as to overall count the target device number and the final
* message arrival number of the batch of push requests.
*
* @param Custom notification id, up to 16 characters and can only consist of English letters and numbers.
*/
public void setNotificationId(String notificationId) {
this.notificationId = notificationId;
}
}