diff --git a/pom.xml b/pom.xml
index 502745bb..e6c33d62 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,7 +35,7 @@
https://github.com/jpush/jpush-api-java-client
scm:git:git@github.com:jpush/jpush-api-java-client.git
scm:git:git@github.com:jpush/jpush-api-java-client.git
- v3.2.7
+ v3.2.8
diff --git a/src/main/java/cn/jpush/api/JPushClient.java b/src/main/java/cn/jpush/api/JPushClient.java
index dbdf8feb..68aac713 100644
--- a/src/main/java/cn/jpush/api/JPushClient.java
+++ b/src/main/java/cn/jpush/api/JPushClient.java
@@ -138,12 +138,12 @@ public JPushClient(String masterSecret, String appKey, int maxRetryTimes, HttpPr
public JPushClient(String masterSecret, String appKey, int maxRetryTimes, HttpProxy proxy, ClientConfig conf,
boolean apnsProduction, long timeToLive) {
conf.setMaxRetryTimes(maxRetryTimes);
+ conf.setApnsProduction(apnsProduction);
+ conf.setTimeToLive(timeToLive);
_pushClient = new PushClient(masterSecret, appKey, proxy, conf);
_reportClient = new ReportClient(masterSecret, appKey, proxy, conf);
_deviceClient = new DeviceClient(masterSecret, appKey, proxy, conf);
_scheduleClient = new ScheduleClient(masterSecret, appKey, proxy, conf);
- _pushClient.setDefaults(apnsProduction, timeToLive);
-
}
/**
@@ -159,7 +159,10 @@ public JPushClient(String masterSecret, String appKey, int maxRetryTimes, HttpPr
*/
@Deprecated
public JPushClient(String masterSecret, String appKey, boolean apnsProduction, long timeToLive) {
- _pushClient = new PushClient(masterSecret, appKey, apnsProduction, timeToLive);
+ ClientConfig conf = ClientConfig.getInstance();
+ conf.setApnsProduction(apnsProduction);
+ conf.setTimeToLive(timeToLive);
+ _pushClient = new PushClient(masterSecret, appKey);
_reportClient = new ReportClient(masterSecret, appKey);
_deviceClient = new DeviceClient(masterSecret, appKey);
_scheduleClient = new ScheduleClient(masterSecret, appKey);
diff --git a/src/main/java/cn/jpush/api/common/resp/BaseResult.java b/src/main/java/cn/jpush/api/common/resp/BaseResult.java
index c54c67b6..ab1837c3 100644
--- a/src/main/java/cn/jpush/api/common/resp/BaseResult.java
+++ b/src/main/java/cn/jpush/api/common/resp/BaseResult.java
@@ -3,14 +3,18 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-public abstract class BaseResult implements IRateLimiting {
+import java.io.Serializable;
+
+public abstract class BaseResult implements IRateLimiting, Serializable {
public static final int ERROR_CODE_NONE = -1;
public static final int ERROR_CODE_OK = 0;
public static final String ERROR_MESSAGE_NONE = "None error message.";
protected static final int RESPONSE_OK = 200;
protected static Gson _gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
-
+
+ private static final long serialVersionUID = 4810924314887130678L;
+
private ResponseWrapper responseWrapper;
public void setResponseWrapper(ResponseWrapper responseWrapper) {
diff --git a/src/main/java/cn/jpush/api/common/resp/ResponseWrapper.java b/src/main/java/cn/jpush/api/common/resp/ResponseWrapper.java
index 40fd1d9d..81a193c6 100644
--- a/src/main/java/cn/jpush/api/common/resp/ResponseWrapper.java
+++ b/src/main/java/cn/jpush/api/common/resp/ResponseWrapper.java
@@ -9,10 +9,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ResponseWrapper {
+import java.io.Serializable;
+
+public class ResponseWrapper implements Serializable {
+
private static final Logger LOG = LoggerFactory.getLogger(ResponseWrapper.class);
private static final int RESPONSE_CODE_NONE = -1;
-
+ private static final long serialVersionUID = -4227962073448507865L;
+
private static Gson _gson = new Gson();
private static JsonParser jsonParser = new JsonParser();
diff --git a/src/main/java/cn/jpush/api/device/DeviceClient.java b/src/main/java/cn/jpush/api/device/DeviceClient.java
index d1f21747..5ef25460 100644
--- a/src/main/java/cn/jpush/api/device/DeviceClient.java
+++ b/src/main/java/cn/jpush/api/device/DeviceClient.java
@@ -138,7 +138,12 @@ public DefaultResult updateDeviceTagAlias(String registrationId, String alias,
public DefaultResult bindMobile(String registrationId, String mobile)
throws APIConnectionException, APIRequestException
{
- Preconditions.checkArgument(StringUtils.isMobileNumber(mobile), "The mobile format is incorrect. " + mobile);
+
+ if ("".equals(mobile)) {
+ // delete bind while mobile is empty.
+ } else {
+ Preconditions.checkArgument(StringUtils.isMobileNumber(mobile), "The mobile format is incorrect. " + mobile);
+ }
String url = hostName + devicesPath + "/" + registrationId;
JsonObject top = new JsonObject();
diff --git a/src/main/java/cn/jpush/api/device/OnlineStatus.java b/src/main/java/cn/jpush/api/device/OnlineStatus.java
index 3a28fc7f..7b2fcdba 100644
--- a/src/main/java/cn/jpush/api/device/OnlineStatus.java
+++ b/src/main/java/cn/jpush/api/device/OnlineStatus.java
@@ -1,9 +1,13 @@
package cn.jpush.api.device;
-public class OnlineStatus {
+import java.io.Serializable;
- Boolean online;
- String last_online_time;
+public class OnlineStatus implements Serializable {
+
+ private static final long serialVersionUID = -5436655826293828109L;
+
+ private Boolean online;
+ private String last_online_time;
public Boolean getOnline() {
return online;
diff --git a/src/main/java/cn/jpush/api/device/TagAliasResult.java b/src/main/java/cn/jpush/api/device/TagAliasResult.java
index 569fff1e..5dd15cce 100644
--- a/src/main/java/cn/jpush/api/device/TagAliasResult.java
+++ b/src/main/java/cn/jpush/api/device/TagAliasResult.java
@@ -1,13 +1,13 @@
package cn.jpush.api.device;
-import java.util.List;
-
import cn.jpush.api.common.resp.BaseResult;
-
import com.google.gson.annotations.Expose;
+import java.util.List;
+
public class TagAliasResult extends BaseResult {
+ private static final long serialVersionUID = -4765083329495728276L;
@Expose public List tags;
@Expose public String alias;
diff --git a/src/main/java/cn/jpush/api/device/TagListResult.java b/src/main/java/cn/jpush/api/device/TagListResult.java
index 426ee47d..86a457fb 100644
--- a/src/main/java/cn/jpush/api/device/TagListResult.java
+++ b/src/main/java/cn/jpush/api/device/TagListResult.java
@@ -1,14 +1,14 @@
package cn.jpush.api.device;
-import java.util.ArrayList;
-import java.util.List;
-
import cn.jpush.api.common.resp.BaseResult;
-
import com.google.gson.annotations.Expose;
+import java.util.ArrayList;
+import java.util.List;
+
public class TagListResult extends BaseResult {
-
+
+ private static final long serialVersionUID = -5395153728332839175L;
@Expose public List tags = new ArrayList();
}
diff --git a/src/main/java/cn/jpush/api/push/PushResult.java b/src/main/java/cn/jpush/api/push/PushResult.java
index 51576c3b..0874c50f 100644
--- a/src/main/java/cn/jpush/api/push/PushResult.java
+++ b/src/main/java/cn/jpush/api/push/PushResult.java
@@ -1,11 +1,12 @@
package cn.jpush.api.push;
import cn.jpush.api.common.resp.BaseResult;
-
import com.google.gson.annotations.Expose;
public class PushResult extends BaseResult {
-
+
+ private static final long serialVersionUID = 93783137655776743L;
+
@Expose public long msg_id;
@Expose public int sendno;
diff --git a/src/main/java/cn/jpush/api/report/MessagesResult.java b/src/main/java/cn/jpush/api/report/MessagesResult.java
index 3c0a04a7..dcac3d1b 100644
--- a/src/main/java/cn/jpush/api/report/MessagesResult.java
+++ b/src/main/java/cn/jpush/api/report/MessagesResult.java
@@ -11,6 +11,7 @@
public class MessagesResult extends BaseResult {
private static final Type MESSAGE_TYPE = new TypeToken>() {}.getType();
+ private static final long serialVersionUID = -1582895355000647292L;
@Expose
public List messages = new ArrayList();
diff --git a/src/main/java/cn/jpush/api/report/ReceivedsResult.java b/src/main/java/cn/jpush/api/report/ReceivedsResult.java
index 3187d0cd..3eeeab11 100644
--- a/src/main/java/cn/jpush/api/report/ReceivedsResult.java
+++ b/src/main/java/cn/jpush/api/report/ReceivedsResult.java
@@ -11,6 +11,7 @@
public class ReceivedsResult extends BaseResult {
private static final Type RECEIVED_TYPE = new TypeToken>() {}.getType();
+ private static final long serialVersionUID = 1761456104618847304L;
@Expose
public List received_list = new ArrayList();
@@ -24,7 +25,7 @@ public static class Received {
@Expose
public int ios_apns_sent;
@Expose
- public int ios_msg_receive;
+ public int ios_msg_received;
@Expose
public int wp_mpns_sent;
}
diff --git a/src/main/java/cn/jpush/api/report/UsersResult.java b/src/main/java/cn/jpush/api/report/UsersResult.java
index 6ddb8284..5f5f0292 100644
--- a/src/main/java/cn/jpush/api/report/UsersResult.java
+++ b/src/main/java/cn/jpush/api/report/UsersResult.java
@@ -11,6 +11,7 @@
public class UsersResult extends BaseResult {
+ private static final long serialVersionUID = -963296929272770550L;
@Expose public TimeUnit time_unit;
@Expose public String start;
@Expose public int duration;
diff --git a/src/main/java/cn/jpush/api/schedule/ScheduleClient.java b/src/main/java/cn/jpush/api/schedule/ScheduleClient.java
index fd492b14..5f2d8a32 100644
--- a/src/main/java/cn/jpush/api/schedule/ScheduleClient.java
+++ b/src/main/java/cn/jpush/api/schedule/ScheduleClient.java
@@ -21,6 +21,12 @@ public class ScheduleClient {
private String hostName;
private String schedulePath;
+ // If not present, true by default.
+ private int apnsProduction;
+
+ // If not present, the default value is 86400(s) (one day)
+ private long timeToLive;
+
public ScheduleClient(String masterSecret, String appkey) {
this(masterSecret, appkey, null, ClientConfig.getInstance());
}
@@ -47,6 +53,8 @@ public ScheduleClient(String masterSecret, String appKey, int maxRetryTimes, Htt
hostName = (String) conf.get(ClientConfig.SCHEDULE_HOST_NAME);
schedulePath = (String) conf.get(ClientConfig.SCHEDULE_PATH);
+ apnsProduction = (Integer) conf.get(ClientConfig.APNS_PRODUCTION);
+ timeToLive = (Long) conf.get(ClientConfig.TIME_TO_LIVE);
String authCode = ServiceHelper.getBasicAuthorization(appKey, masterSecret);
this._httpClient = new NativeHttpClient(authCode, proxy, conf);
@@ -63,6 +71,8 @@ public ScheduleClient(String masterSecret, String appKey, HttpProxy proxy, Clien
ServiceHelper.checkBasic(appKey, masterSecret);
hostName = (String) conf.get(ClientConfig.SCHEDULE_HOST_NAME);
schedulePath = (String) conf.get(ClientConfig.SCHEDULE_PATH);
+ apnsProduction = (Integer) conf.get(ClientConfig.APNS_PRODUCTION);
+ timeToLive = (Long) conf.get(ClientConfig.TIME_TO_LIVE);
String authCode = ServiceHelper.getBasicAuthorization(appKey, masterSecret);
this._httpClient = new NativeHttpClient(authCode, proxy, conf);
@@ -72,6 +82,16 @@ public ScheduleResult createSchedule(SchedulePayload payload) throws APIConnecti
Preconditions.checkArgument(null != payload, "payload should not be null");
+ if (apnsProduction > 0) {
+ payload.resetPushApnsProduction(true);
+ } else if(apnsProduction == 0) {
+ payload.resetPushApnsProduction(false);
+ }
+
+ if (timeToLive >= 0) {
+ payload.resetPushTimeToLive(timeToLive);
+ }
+
ResponseWrapper response = _httpClient.sendPost(hostName + schedulePath, payload.toString());
return ScheduleResult.fromResponse(response, ScheduleResult.class);
}
@@ -97,6 +117,16 @@ public ScheduleResult updateSchedule(String scheduleId, SchedulePayload payload)
Preconditions.checkArgument(StringUtils.isNotEmpty(scheduleId), "scheduleId should not be empty");
Preconditions.checkArgument(null != payload, "payload should not be null");
+ if (apnsProduction > 0) {
+ payload.resetPushApnsProduction(true);
+ } else if(apnsProduction == 0) {
+ payload.resetPushApnsProduction(false);
+ }
+
+ if (timeToLive >= 0) {
+ payload.resetPushTimeToLive(timeToLive);
+ }
+
ResponseWrapper response = _httpClient.sendPut(hostName + schedulePath + "/" + scheduleId,
payload.toString());
return ScheduleResult.fromResponse(response, ScheduleResult.class);
diff --git a/src/main/java/cn/jpush/api/schedule/ScheduleListResult.java b/src/main/java/cn/jpush/api/schedule/ScheduleListResult.java
index eeda28db..2dd5cb51 100644
--- a/src/main/java/cn/jpush/api/schedule/ScheduleListResult.java
+++ b/src/main/java/cn/jpush/api/schedule/ScheduleListResult.java
@@ -8,6 +8,7 @@
public class ScheduleListResult extends BaseResult{
+ private static final long serialVersionUID = 86248096939746151L;
@Expose int total_count;
@Expose int total_pages;
@Expose int page;
diff --git a/src/main/java/cn/jpush/api/schedule/ScheduleResult.java b/src/main/java/cn/jpush/api/schedule/ScheduleResult.java
index 50619aa4..d620c784 100644
--- a/src/main/java/cn/jpush/api/schedule/ScheduleResult.java
+++ b/src/main/java/cn/jpush/api/schedule/ScheduleResult.java
@@ -6,6 +6,7 @@
public class ScheduleResult extends BaseResult{
+ private static final long serialVersionUID = 995450157929190757L;
@Expose String schedule_id;
@Expose String name;
@Expose Boolean enabled;
diff --git a/src/main/java/cn/jpush/api/schedule/model/SchedulePayload.java b/src/main/java/cn/jpush/api/schedule/model/SchedulePayload.java
index 2fe0302f..c0364e1e 100644
--- a/src/main/java/cn/jpush/api/schedule/model/SchedulePayload.java
+++ b/src/main/java/cn/jpush/api/schedule/model/SchedulePayload.java
@@ -49,6 +49,18 @@ public String toString() {
return gson.toJson(toJSON());
}
+ public void resetPushApnsProduction(boolean apnsProduction) {
+ if(null != push) {
+ push.resetOptionsApnsProduction(apnsProduction);
+ }
+ }
+
+ public void resetPushTimeToLive(long timeToLive) {
+ if(null != push) {
+ push.resetOptionsTimeToLive(timeToLive);
+ }
+ }
+
public static class Builder{
private String name;
private Boolean enabled;