@@ -14,6 +14,7 @@ public class Options implements PushModel {
14
14
private static final String TIME_TO_LIVE = "time_to_live" ;
15
15
private static final String APNS_PRODUCTION = "apns_production" ;
16
16
private static final String BIG_PUSH_DURATION = "big_push_duration" ;
17
+ private static final String APNS_COLLAPSE_ID = "apns_collapse_id" ;
17
18
18
19
private static final long NONE_TIME_TO_LIVE = -1 ;
19
20
@@ -22,14 +23,16 @@ public class Options implements PushModel {
22
23
private long timeToLive ;
23
24
private boolean apnsProduction ;
24
25
private int bigPushDuration ; // minutes
26
+ private String apnsCollapseId ;
25
27
26
28
private Options (int sendno , long overrideMsgId , long timeToLive , boolean apnsProduction ,
27
- int bigPushDuration ) {
29
+ int bigPushDuration , String apnsCollapseId ) {
28
30
this .sendno = sendno ;
29
31
this .overrideMsgId = overrideMsgId ;
30
32
this .timeToLive = timeToLive ;
31
33
this .apnsProduction = apnsProduction ;
32
34
this .bigPushDuration = bigPushDuration ;
35
+ this .apnsCollapseId = apnsCollapseId ;
33
36
}
34
37
35
38
public static Builder newBuilder () {
@@ -78,6 +81,10 @@ public JsonElement toJSON() {
78
81
if (bigPushDuration > 0 ) {
79
82
json .add (BIG_PUSH_DURATION , new JsonPrimitive (bigPushDuration ));
80
83
}
84
+
85
+ if (apnsCollapseId != null ) {
86
+ json .add (APNS_COLLAPSE_ID , new JsonPrimitive (apnsCollapseId ));
87
+ }
81
88
82
89
return json ;
83
90
}
@@ -88,6 +95,7 @@ public static class Builder {
88
95
private long timeToLive = NONE_TIME_TO_LIVE ;
89
96
private boolean apnsProduction = false ;
90
97
private int bigPushDuration = 0 ;
98
+ private String apnsCollapseId ;
91
99
92
100
public Builder setSendno (int sendno ) {
93
101
this .sendno = sendno ;
@@ -108,12 +116,17 @@ public Builder setApnsProduction(boolean apnsProduction) {
108
116
this .apnsProduction = apnsProduction ;
109
117
return this ;
110
118
}
119
+
120
+ public Builder setApnsCollapseId (String id ) {
121
+ this .apnsCollapseId = id ;
122
+ return this ;
123
+ }
111
124
112
125
public Builder setBigPushDuration (int bigPushDuration ) {
113
126
this .bigPushDuration = bigPushDuration ;
114
127
return this ;
115
128
}
116
-
129
+
117
130
public Options build () {
118
131
Preconditions .checkArgument (sendno >= 0 , "sendno should be greater than 0." );
119
132
Preconditions .checkArgument (overrideMsgId >= 0 , "override_msg_id should be greater than 0." );
@@ -123,7 +136,7 @@ public Options build() {
123
136
sendno = ServiceHelper .generateSendno ();
124
137
}
125
138
126
- return new Options (sendno , overrideMsgId , timeToLive , apnsProduction , bigPushDuration );
139
+ return new Options (sendno , overrideMsgId , timeToLive , apnsProduction , bigPushDuration , apnsCollapseId );
127
140
}
128
141
}
129
142
0 commit comments