@@ -14,6 +14,7 @@ public class Options implements PushModel {
1414 private static final String TIME_TO_LIVE = "time_to_live" ;
1515 private static final String APNS_PRODUCTION = "apns_production" ;
1616 private static final String BIG_PUSH_DURATION = "big_push_duration" ;
17+ private static final String APNS_COLLAPSE_ID = "apns_collapse_id" ;
1718
1819 private static final long NONE_TIME_TO_LIVE = -1 ;
1920
@@ -22,14 +23,16 @@ public class Options implements PushModel {
2223 private long timeToLive ;
2324 private boolean apnsProduction ;
2425 private int bigPushDuration ; // minutes
26+ private String apnsCollapseId ;
2527
2628 private Options (int sendno , long overrideMsgId , long timeToLive , boolean apnsProduction ,
27- int bigPushDuration ) {
29+ int bigPushDuration , String apnsCollapseId ) {
2830 this .sendno = sendno ;
2931 this .overrideMsgId = overrideMsgId ;
3032 this .timeToLive = timeToLive ;
3133 this .apnsProduction = apnsProduction ;
3234 this .bigPushDuration = bigPushDuration ;
35+ this .apnsCollapseId = apnsCollapseId ;
3336 }
3437
3538 public static Builder newBuilder () {
@@ -78,6 +81,10 @@ public JsonElement toJSON() {
7881 if (bigPushDuration > 0 ) {
7982 json .add (BIG_PUSH_DURATION , new JsonPrimitive (bigPushDuration ));
8083 }
84+
85+ if (apnsCollapseId != null ) {
86+ json .add (APNS_COLLAPSE_ID , new JsonPrimitive (apnsCollapseId ));
87+ }
8188
8289 return json ;
8390 }
@@ -88,6 +95,7 @@ public static class Builder {
8895 private long timeToLive = NONE_TIME_TO_LIVE ;
8996 private boolean apnsProduction = false ;
9097 private int bigPushDuration = 0 ;
98+ private String apnsCollapseId ;
9199
92100 public Builder setSendno (int sendno ) {
93101 this .sendno = sendno ;
@@ -108,12 +116,17 @@ public Builder setApnsProduction(boolean apnsProduction) {
108116 this .apnsProduction = apnsProduction ;
109117 return this ;
110118 }
119+
120+ public Builder setApnsCollapseId (String id ) {
121+ this .apnsCollapseId = id ;
122+ return this ;
123+ }
111124
112125 public Builder setBigPushDuration (int bigPushDuration ) {
113126 this .bigPushDuration = bigPushDuration ;
114127 return this ;
115128 }
116-
129+
117130 public Options build () {
118131 Preconditions .checkArgument (sendno >= 0 , "sendno should be greater than 0." );
119132 Preconditions .checkArgument (overrideMsgId >= 0 , "override_msg_id should be greater than 0." );
@@ -123,7 +136,7 @@ public Options build() {
123136 sendno = ServiceHelper .generateSendno ();
124137 }
125138
126- return new Options (sendno , overrideMsgId , timeToLive , apnsProduction , bigPushDuration );
139+ return new Options (sendno , overrideMsgId , timeToLive , apnsProduction , bigPushDuration , apnsCollapseId );
127140 }
128141 }
129142
0 commit comments