11
11
import java .util .Map ;
12
12
import java .util .Set ;
13
13
14
+ /**
15
+ * 参考文档:https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push#options
16
+ *
17
+ * <p><b>Options</b></p>
18
+ * <br>
19
+ * <ul>
20
+ * <li>sendno: 推送序号 </li>
21
+ * <li>time_to_live: 离线消息保留时长 (秒) </li>
22
+ * <li>override_msg_id: 要覆盖的消息 ID </li>
23
+ * <li>apns_production: APNs 是否生产环境 </li>
24
+ * <li>apns_collapse_id: 更新 iOS 通知的标识符 </li>
25
+ * <li>big_push_duration: 定速推送时长 (分钟) </li>
26
+ * <li>third_party_channel: 推送请求下发通道 </li>
27
+ * <li>classification: 消息类型分类,极光不对指定的消息类型进行判断或校准,会以开发者自行指定的消息类型适配 Android 厂商通道。不填默认为 0 </li>
28
+ * </ul>
29
+ */
14
30
public class Options implements PushModel {
15
31
16
32
private static final String SENDNO = "sendno" ;
@@ -20,6 +36,7 @@ public class Options implements PushModel {
20
36
private static final String BIG_PUSH_DURATION = "big_push_duration" ;
21
37
private static final String APNS_COLLAPSE_ID = "apns_collapse_id" ;
22
38
private static final String THIRD_PARTH_CHANNEl = "third_party_channel" ;
39
+ private static final String CLASSIFICATION = "classification" ;
23
40
24
41
private static final long NONE_TIME_TO_LIVE = -1 ;
25
42
@@ -30,45 +47,20 @@ public class Options implements PushModel {
30
47
// minutes
31
48
private int bigPushDuration ;
32
49
private String apnsCollapseId ;
33
- private final Map <String , JsonPrimitive > customData ;
34
-
35
-
50
+ private int classification ;
36
51
/**
37
- * {
38
- * "third_party_channel":{
39
- * "xiaomi":{
40
- * "distribution":"ospush",
41
- * "channel_id":"*******"
42
- * },
43
- * "huawei":{
44
- * "distribution":"jpush"
45
- * },
46
- * "meizu":{
47
- * "distribution":"jpush"
48
- * },
49
- * "fcm":{
50
- * "distribution":"ospush"
51
- * },
52
- * "oppo":{
53
- * "distribution":"ospush",
54
- * "channel_id":"*******"
55
- * },
56
- * "vivo":{
57
- * "distribution":"ospush",
58
- * "classification":0 // 2020/06 新增,和vivo官方字段含义一致 0 代表运营消息,1 代表系统消息,不填vivo官方默认为0
59
- * // 使用此字段时,需使用setThirdPartyChannelV2方法,因为此值只能为整数形式
60
- * }
61
- * }
62
- * }
52
+ * 参考:https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push#third_party_channel-%E8%AF%B4%E6%98%8E
63
53
*/
64
54
private Map <String , JsonObject > thirdPartyChannel ;
55
+ private final Map <String , JsonPrimitive > customData ;
65
56
66
57
private Options (int sendno ,
67
58
long overrideMsgId ,
68
59
long timeToLive ,
69
60
boolean apnsProduction ,
70
61
int bigPushDuration ,
71
62
String apnsCollapseId ,
63
+ int classification ,
72
64
Map <String , JsonObject > thirdPartyChannel ,
73
65
Map <String , JsonPrimitive > customData ) {
74
66
this .sendno = sendno ;
@@ -77,6 +69,7 @@ private Options(int sendno,
77
69
this .apnsProduction = apnsProduction ;
78
70
this .bigPushDuration = bigPushDuration ;
79
71
this .apnsCollapseId = apnsCollapseId ;
72
+ this .classification = classification ;
80
73
this .thirdPartyChannel = thirdPartyChannel ;
81
74
this .customData = customData ;
82
75
}
@@ -132,6 +125,8 @@ public JsonElement toJSON() {
132
125
json .add (APNS_COLLAPSE_ID , new JsonPrimitive (apnsCollapseId ));
133
126
}
134
127
128
+ json .add (CLASSIFICATION , new JsonPrimitive (classification ));
129
+
135
130
if (null != thirdPartyChannel && thirdPartyChannel .size () > 0 ) {
136
131
JsonObject partyChannel = new JsonObject ();
137
132
for (Map .Entry <String , JsonObject > entry : thirdPartyChannel .entrySet ()) {
@@ -158,6 +153,7 @@ public static class Builder {
158
153
private boolean apnsProduction = false ;
159
154
private int bigPushDuration = 0 ;
160
155
private String apnsCollapseId ;
156
+ private int classification ;
161
157
private Map <String , JsonObject > thirdPartyChannel ;
162
158
private Map <String , JsonPrimitive > customData ;
163
159
@@ -191,6 +187,11 @@ public Builder setBigPushDuration(int bigPushDuration) {
191
187
return this ;
192
188
}
193
189
190
+ public Builder setClassification (int classification ) {
191
+ this .classification = classification ;
192
+ return this ;
193
+ }
194
+
194
195
@ Deprecated
195
196
public Map <String , Map <String , String >> getThirdPartyChannel () {
196
197
if (null != thirdPartyChannel ) {
@@ -248,7 +249,7 @@ public Builder addCustom(Map<String, String> extras) {
248
249
}
249
250
250
251
public Builder addCustom (String key , Number value ) {
251
- Preconditions .checkArgument (! (null == key ), "Key should not be null." );
252
+ Preconditions .checkArgument (!(null == key ), "Key should not be null." );
252
253
if (customData == null ) {
253
254
customData = new LinkedHashMap <String , JsonPrimitive >();
254
255
}
@@ -257,7 +258,7 @@ public Builder addCustom(String key, Number value) {
257
258
}
258
259
259
260
public Builder addCustom (String key , String value ) {
260
- Preconditions .checkArgument (! (null == key ), "Key should not be null." );
261
+ Preconditions .checkArgument (!(null == key ), "Key should not be null." );
261
262
if (customData == null ) {
262
263
customData = new LinkedHashMap <String , JsonPrimitive >();
263
264
}
@@ -266,7 +267,7 @@ public Builder addCustom(String key, String value) {
266
267
}
267
268
268
269
public Builder addCustom (String key , Boolean value ) {
269
- Preconditions .checkArgument (! (null == key ), "Key should not be null." );
270
+ Preconditions .checkArgument (!(null == key ), "Key should not be null." );
270
271
if (customData == null ) {
271
272
customData = new LinkedHashMap <String , JsonPrimitive >();
272
273
}
@@ -284,7 +285,7 @@ public Options build() {
284
285
sendno = ServiceHelper .generateSendno ();
285
286
}
286
287
287
- return new Options (sendno , overrideMsgId , timeToLive , apnsProduction , bigPushDuration , apnsCollapseId , thirdPartyChannel , customData );
288
+ return new Options (sendno , overrideMsgId , timeToLive , apnsProduction , bigPushDuration , apnsCollapseId , classification , thirdPartyChannel , customData );
288
289
}
289
290
}
290
291
0 commit comments