1111import java .util .Map ;
1212import java .util .Set ;
1313
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+ */
1430public class Options implements PushModel {
1531
1632 private static final String SENDNO = "sendno" ;
@@ -20,6 +36,7 @@ public class Options implements PushModel {
2036 private static final String BIG_PUSH_DURATION = "big_push_duration" ;
2137 private static final String APNS_COLLAPSE_ID = "apns_collapse_id" ;
2238 private static final String THIRD_PARTH_CHANNEl = "third_party_channel" ;
39+ private static final String CLASSIFICATION = "classification" ;
2340
2441 private static final long NONE_TIME_TO_LIVE = -1 ;
2542
@@ -30,45 +47,20 @@ public class Options implements PushModel {
3047 // minutes
3148 private int bigPushDuration ;
3249 private String apnsCollapseId ;
33- private final Map <String , JsonPrimitive > customData ;
34-
35-
50+ private int classification ;
3651 /**
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
6353 */
6454 private Map <String , JsonObject > thirdPartyChannel ;
55+ private final Map <String , JsonPrimitive > customData ;
6556
6657 private Options (int sendno ,
6758 long overrideMsgId ,
6859 long timeToLive ,
6960 boolean apnsProduction ,
7061 int bigPushDuration ,
7162 String apnsCollapseId ,
63+ int classification ,
7264 Map <String , JsonObject > thirdPartyChannel ,
7365 Map <String , JsonPrimitive > customData ) {
7466 this .sendno = sendno ;
@@ -77,6 +69,7 @@ private Options(int sendno,
7769 this .apnsProduction = apnsProduction ;
7870 this .bigPushDuration = bigPushDuration ;
7971 this .apnsCollapseId = apnsCollapseId ;
72+ this .classification = classification ;
8073 this .thirdPartyChannel = thirdPartyChannel ;
8174 this .customData = customData ;
8275 }
@@ -132,6 +125,8 @@ public JsonElement toJSON() {
132125 json .add (APNS_COLLAPSE_ID , new JsonPrimitive (apnsCollapseId ));
133126 }
134127
128+ json .add (CLASSIFICATION , new JsonPrimitive (classification ));
129+
135130 if (null != thirdPartyChannel && thirdPartyChannel .size () > 0 ) {
136131 JsonObject partyChannel = new JsonObject ();
137132 for (Map .Entry <String , JsonObject > entry : thirdPartyChannel .entrySet ()) {
@@ -158,6 +153,7 @@ public static class Builder {
158153 private boolean apnsProduction = false ;
159154 private int bigPushDuration = 0 ;
160155 private String apnsCollapseId ;
156+ private int classification ;
161157 private Map <String , JsonObject > thirdPartyChannel ;
162158 private Map <String , JsonPrimitive > customData ;
163159
@@ -191,6 +187,11 @@ public Builder setBigPushDuration(int bigPushDuration) {
191187 return this ;
192188 }
193189
190+ public Builder setClassification (int classification ) {
191+ this .classification = classification ;
192+ return this ;
193+ }
194+
194195 @ Deprecated
195196 public Map <String , Map <String , String >> getThirdPartyChannel () {
196197 if (null != thirdPartyChannel ) {
@@ -248,7 +249,7 @@ public Builder addCustom(Map<String, String> extras) {
248249 }
249250
250251 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." );
252253 if (customData == null ) {
253254 customData = new LinkedHashMap <String , JsonPrimitive >();
254255 }
@@ -257,7 +258,7 @@ public Builder addCustom(String key, Number value) {
257258 }
258259
259260 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." );
261262 if (customData == null ) {
262263 customData = new LinkedHashMap <String , JsonPrimitive >();
263264 }
@@ -266,7 +267,7 @@ public Builder addCustom(String key, String value) {
266267 }
267268
268269 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." );
270271 if (customData == null ) {
271272 customData = new LinkedHashMap <String , JsonPrimitive >();
272273 }
@@ -284,7 +285,7 @@ public Options build() {
284285 sendno = ServiceHelper .generateSendno ();
285286 }
286287
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 );
288289 }
289290 }
290291
0 commit comments