@@ -21,6 +21,12 @@ public class ScheduleClient {
2121 private String hostName ;
2222 private String schedulePath ;
2323
24+ // If not present, true by default.
25+ private int apnsProduction ;
26+
27+ // If not present, the default value is 86400(s) (one day)
28+ private long timeToLive ;
29+
2430 public ScheduleClient (String masterSecret , String appkey ) {
2531 this (masterSecret , appkey , null , ClientConfig .getInstance ());
2632 }
@@ -47,6 +53,8 @@ public ScheduleClient(String masterSecret, String appKey, int maxRetryTimes, Htt
4753
4854 hostName = (String ) conf .get (ClientConfig .SCHEDULE_HOST_NAME );
4955 schedulePath = (String ) conf .get (ClientConfig .SCHEDULE_PATH );
56+ apnsProduction = (Integer ) conf .get (ClientConfig .APNS_PRODUCTION );
57+ timeToLive = (Long ) conf .get (ClientConfig .TIME_TO_LIVE );
5058
5159 String authCode = ServiceHelper .getBasicAuthorization (appKey , masterSecret );
5260 this ._httpClient = new NativeHttpClient (authCode , proxy , conf );
@@ -63,6 +71,8 @@ public ScheduleClient(String masterSecret, String appKey, HttpProxy proxy, Clien
6371 ServiceHelper .checkBasic (appKey , masterSecret );
6472 hostName = (String ) conf .get (ClientConfig .SCHEDULE_HOST_NAME );
6573 schedulePath = (String ) conf .get (ClientConfig .SCHEDULE_PATH );
74+ apnsProduction = (Integer ) conf .get (ClientConfig .APNS_PRODUCTION );
75+ timeToLive = (Long ) conf .get (ClientConfig .TIME_TO_LIVE );
6676
6777 String authCode = ServiceHelper .getBasicAuthorization (appKey , masterSecret );
6878 this ._httpClient = new NativeHttpClient (authCode , proxy , conf );
@@ -72,6 +82,16 @@ public ScheduleResult createSchedule(SchedulePayload payload) throws APIConnecti
7282
7383 Preconditions .checkArgument (null != payload , "payload should not be null" );
7484
85+ if (apnsProduction > 0 ) {
86+ payload .resetPushApnsProduction (true );
87+ } else if (apnsProduction == 0 ) {
88+ payload .resetPushApnsProduction (false );
89+ }
90+
91+ if (timeToLive >= 0 ) {
92+ payload .resetPushTimeToLive (timeToLive );
93+ }
94+
7595 ResponseWrapper response = _httpClient .sendPost (hostName + schedulePath , payload .toString ());
7696 return ScheduleResult .fromResponse (response , ScheduleResult .class );
7797 }
@@ -97,6 +117,16 @@ public ScheduleResult updateSchedule(String scheduleId, SchedulePayload payload)
97117 Preconditions .checkArgument (StringUtils .isNotEmpty (scheduleId ), "scheduleId should not be empty" );
98118 Preconditions .checkArgument (null != payload , "payload should not be null" );
99119
120+ if (apnsProduction > 0 ) {
121+ payload .resetPushApnsProduction (true );
122+ } else if (apnsProduction == 0 ) {
123+ payload .resetPushApnsProduction (false );
124+ }
125+
126+ if (timeToLive >= 0 ) {
127+ payload .resetPushTimeToLive (timeToLive );
128+ }
129+
100130 ResponseWrapper response = _httpClient .sendPut (hostName + schedulePath + "/" + scheduleId ,
101131 payload .toString ());
102132 return ScheduleResult .fromResponse (response , ScheduleResult .class );
0 commit comments