Skip to content

Commit a415497

Browse files
author
zhanq
committed
add:同步官网更新
1 parent 4492798 commit a415497

File tree

6 files changed

+100
-108
lines changed

6 files changed

+100
-108
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>cn.jpush.api</groupId>
55
<artifactId>jpush-client</artifactId>
6-
<version>3.6.8</version>
6+
<version>3.6.9</version>
77
<packaging>jar</packaging>
88
<url>https://github.com/jpush/jpush-api-java-client</url>
99
<name>JPush API Java Client</name>

src/main/java/cn/jpush/api/push/model/Notification3rd.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class Notification3rd implements PushModel{
2424
private static final String URI_ACTIVITY = "uri_activity";
2525
private static final String URI_ACTION = "uri_action";
2626
private static final String BADGE_ADD_NUM = "badge_add_num";
27+
private static final String BADGE_SET_NUM = "badge_set_num";
2728
private static final String BADGE_CLASS = "badge_class";
2829
private static final String SOUND = "sound";
2930
private static final String EXTRAS = "extras";
@@ -35,6 +36,7 @@ public class Notification3rd implements PushModel{
3536
private final String uri_activity;
3637
private final String uri_action;
3738
private final int badge_add_num;
39+
private final int badge_set_num;
3840
private final String badge_class;
3941
private final String sound;
4042
private final Map<String, String> extras;
@@ -43,7 +45,7 @@ public class Notification3rd implements PushModel{
4345
private final Map<String, JsonObject> jsonExtras;
4446

4547
private Notification3rd(String title, String content, String channel_id,
46-
String uri_activity, String uri_action, int badge_add_num,
48+
String uri_activity, String uri_action, int badge_add_num,int badge_set_num,
4749
String badge_class, String sound,
4850
Map<String, String> extras,
4951
Map<String, Number> numberExtras,
@@ -55,6 +57,7 @@ private Notification3rd(String title, String content, String channel_id,
5557
this.uri_activity = uri_activity;
5658
this.uri_action = uri_action;
5759
this.badge_add_num = badge_add_num;
60+
this.badge_set_num = badge_set_num;
5861
this.badge_class = badge_class;
5962
this.sound = sound;
6063
this.extras = extras;
@@ -97,6 +100,10 @@ public JsonElement toJSON() {
97100
json.addProperty(BADGE_ADD_NUM, badge_add_num);
98101
}
99102

103+
if (0 != badge_set_num) {
104+
json.addProperty(BADGE_SET_NUM, badge_set_num);
105+
}
106+
100107
if (null != badge_class) {
101108
json.addProperty(BADGE_CLASS, badge_class);
102109
}
@@ -164,6 +171,7 @@ public static class Builder{
164171
private String uri_activity;
165172
private String uri_action;
166173
private int badge_add_num;
174+
private int badge_set_num;
167175
private String badge_class;
168176
private String sound;
169177
protected Map<String, String> extrasBuilder;
@@ -201,6 +209,11 @@ public Builder setBadgeAddNum(int badge_add_num) {
201209
return this;
202210
}
203211

212+
public Builder setBadgeSetNum(int badge_set_num) {
213+
this.badge_set_num = badge_set_num;
214+
return this;
215+
}
216+
204217
public Builder setBadgeClass(String badge_class) {
205218
this.badge_class = badge_class;
206219
return this;
@@ -263,7 +276,7 @@ public Builder addExtra(String key, JsonObject value) {
263276
public Notification3rd build() {
264277
Preconditions.checkArgument(content != null && content != "", "content should not be null or empty");
265278

266-
return new Notification3rd(title, content, channel_id, uri_activity, uri_action, badge_add_num,
279+
return new Notification3rd(title, content, channel_id, uri_activity, uri_action, badge_add_num, badge_set_num,
267280
badge_class, sound, extrasBuilder, numberExtrasBuilder, booleanExtrasBuilder, jsonExtrasBuilder);
268281
}
269282
}

src/main/java/cn/jpush/api/push/model/Options.java

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@
1111
import java.util.Map;
1212
import 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+
*/
1430
public 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

src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java

Lines changed: 7 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,13 @@ public class LiveActivity implements PushModel {
1414

1515
private final String iOSEvent;
1616
private final JsonObject iOSContentState;
17-
private final String iOSAlertTitle;
18-
private final String iOSAlertAlternateTitle;
19-
private final String iOSAlertBody;
20-
private final String iOSAlertAlternateBody;
21-
private final String iOSAlertSound;
22-
private final Integer iOSDismissalDate;
23-
24-
public LiveActivity(Boolean apnsProduction, String liveActivityId, String iOSEvent, JsonObject iOSContentState, String iOSAlertTitle, String iOSAlertAlternateTitle, String iOSAlertBody, String iOSAlertAlternateBody, String iOSAlertSound, Integer iOSDismissalDate) {
17+
private final Long iOSDismissalDate;
18+
19+
public LiveActivity(Boolean apnsProduction, String liveActivityId, String iOSEvent, JsonObject iOSContentState, Long iOSDismissalDate) {
2520
this.apnsProduction = apnsProduction;
2621
this.liveActivityId = liveActivityId;
2722
this.iOSEvent = iOSEvent;
2823
this.iOSContentState = iOSContentState;
29-
this.iOSAlertTitle = iOSAlertTitle;
30-
this.iOSAlertAlternateTitle = iOSAlertAlternateTitle;
31-
this.iOSAlertBody = iOSAlertBody;
32-
this.iOSAlertAlternateBody = iOSAlertAlternateBody;
33-
this.iOSAlertSound = iOSAlertSound;
3424
this.iOSDismissalDate = iOSDismissalDate;
3525
}
3626

@@ -43,12 +33,7 @@ public static class Builder {
4333
private String liveActivityId;
4434
private String iOSEvent;
4535
private JsonObject iOSContentState;
46-
private String iOSAlertTitle;
47-
private String iOSAlertAlternateTitle;
48-
private String iOSAlertBody;
49-
private String iOSAlertAlternateBody;
50-
private String iOSAlertSound;
51-
private Integer iOSDismissalDate;
36+
private Long iOSDismissalDate;
5237

5338
public Builder apnsProduction(Boolean apnsProduction) {
5439
this.apnsProduction = apnsProduction;
@@ -91,38 +76,13 @@ public Builder iOSContentState(String key, Boolean value) {
9176
return this;
9277
}
9378

94-
public Builder iOSAlertTitle(String iOSAlertTitle) {
95-
this.iOSAlertTitle = iOSAlertTitle;
96-
return this;
97-
}
98-
99-
public Builder iOSAlertAlternateTitle(String iOSAlertAlternateTitle) {
100-
this.iOSAlertAlternateTitle = iOSAlertAlternateTitle;
101-
return this;
102-
}
103-
104-
public Builder iOSAlertBody(String iOSAlertBody) {
105-
this.iOSAlertBody = iOSAlertBody;
106-
return this;
107-
}
108-
109-
public Builder iOSAlertAlternateBody(String iOSAlertAlternateBody) {
110-
this.iOSAlertAlternateBody = iOSAlertAlternateBody;
111-
return this;
112-
}
113-
114-
public Builder iOSAlertSound(String iOSAlertSound) {
115-
this.iOSAlertSound = iOSAlertSound;
116-
return this;
117-
}
118-
119-
public Builder iOSDismissalDate(Integer iOSDismissalDate) {
79+
public Builder iOSDismissalDate(Long iOSDismissalDate) {
12080
this.iOSDismissalDate = iOSDismissalDate;
12181
return this;
12282
}
12383

12484
public LiveActivity build() {
125-
return new LiveActivity(apnsProduction, liveActivityId, iOSEvent, iOSContentState, iOSAlertTitle, iOSAlertAlternateTitle, iOSAlertBody, iOSAlertAlternateBody, iOSAlertSound, iOSDismissalDate);
85+
return new LiveActivity(apnsProduction, liveActivityId, iOSEvent, iOSContentState, iOSDismissalDate);
12686
}
12787

12888
}
@@ -143,30 +103,11 @@ public JsonElement toJSON() {
143103
if (apnsProduction != null) {
144104
optionsJsonObject.addProperty("apns_production", apnsProduction);
145105
}
146-
if (iOSAlertTitle != null || iOSAlertAlternateTitle != null || iOSAlertBody != null || iOSAlertAlternateBody != null || iOSAlertSound != null) {
147-
optionsJsonObject.addProperty("alternate_set", true);
148-
}
149106

150107
JsonObject liveActivityJsonObject = new JsonObject();
151108
JsonObject iOSJsonObject = new JsonObject();
152109
JsonObject alertJsonObject = new JsonObject();
153110

154-
if (iOSAlertTitle != null) {
155-
alertJsonObject.addProperty("title", iOSAlertTitle);
156-
}
157-
if (iOSAlertAlternateTitle != null) {
158-
alertJsonObject.addProperty("alternate_title", iOSAlertAlternateTitle);
159-
}
160-
if (iOSAlertBody != null) {
161-
alertJsonObject.addProperty("body", iOSAlertBody);
162-
}
163-
if (iOSAlertAlternateBody != null) {
164-
alertJsonObject.addProperty("alternate_body", iOSAlertAlternateBody);
165-
}
166-
if (iOSAlertSound != null) {
167-
alertJsonObject.addProperty("sound", iOSAlertSound);
168-
}
169-
170111
if (iOSEvent != null) {
171112
iOSJsonObject.addProperty("event", iOSEvent);
172113
}
@@ -176,7 +117,7 @@ public JsonElement toJSON() {
176117
if (!alertJsonObject.entrySet().isEmpty()) {
177118
iOSJsonObject.add("alert", alertJsonObject);
178119
}
179-
if (iOSDismissalDate != null) {
120+
if (!alertJsonObject.entrySet().isEmpty()) {
180121
iOSJsonObject.addProperty("dismissal-date", iOSDismissalDate);
181122
}
182123

0 commit comments

Comments
 (0)