diff --git a/pom.xml b/pom.xml
index 79beaa61..c0c6b7d7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
cn.jpush.api
jpush-client
- 3.6.8
+ 3.6.9
jar
https://github.com/jpush/jpush-api-java-client
JPush API Java Client
diff --git a/src/main/java/cn/jpush/api/push/model/Notification3rd.java b/src/main/java/cn/jpush/api/push/model/Notification3rd.java
index 7d0bd71b..8a6f622b 100644
--- a/src/main/java/cn/jpush/api/push/model/Notification3rd.java
+++ b/src/main/java/cn/jpush/api/push/model/Notification3rd.java
@@ -24,6 +24,7 @@ public class Notification3rd implements PushModel{
private static final String URI_ACTIVITY = "uri_activity";
private static final String URI_ACTION = "uri_action";
private static final String BADGE_ADD_NUM = "badge_add_num";
+ private static final String BADGE_SET_NUM = "badge_set_num";
private static final String BADGE_CLASS = "badge_class";
private static final String SOUND = "sound";
private static final String EXTRAS = "extras";
@@ -35,6 +36,7 @@ public class Notification3rd implements PushModel{
private final String uri_activity;
private final String uri_action;
private final int badge_add_num;
+ private final int badge_set_num;
private final String badge_class;
private final String sound;
private final Map extras;
@@ -43,7 +45,7 @@ public class Notification3rd implements PushModel{
private final Map jsonExtras;
private Notification3rd(String title, String content, String channel_id,
- String uri_activity, String uri_action, int badge_add_num,
+ String uri_activity, String uri_action, int badge_add_num,int badge_set_num,
String badge_class, String sound,
Map extras,
Map numberExtras,
@@ -55,6 +57,7 @@ private Notification3rd(String title, String content, String channel_id,
this.uri_activity = uri_activity;
this.uri_action = uri_action;
this.badge_add_num = badge_add_num;
+ this.badge_set_num = badge_set_num;
this.badge_class = badge_class;
this.sound = sound;
this.extras = extras;
@@ -97,6 +100,10 @@ public JsonElement toJSON() {
json.addProperty(BADGE_ADD_NUM, badge_add_num);
}
+ if (0 != badge_set_num) {
+ json.addProperty(BADGE_SET_NUM, badge_set_num);
+ }
+
if (null != badge_class) {
json.addProperty(BADGE_CLASS, badge_class);
}
@@ -164,6 +171,7 @@ public static class Builder{
private String uri_activity;
private String uri_action;
private int badge_add_num;
+ private int badge_set_num;
private String badge_class;
private String sound;
protected Map extrasBuilder;
@@ -201,6 +209,11 @@ public Builder setBadgeAddNum(int badge_add_num) {
return this;
}
+ public Builder setBadgeSetNum(int badge_set_num) {
+ this.badge_set_num = badge_set_num;
+ return this;
+ }
+
public Builder setBadgeClass(String badge_class) {
this.badge_class = badge_class;
return this;
@@ -263,7 +276,7 @@ public Builder addExtra(String key, JsonObject value) {
public Notification3rd build() {
Preconditions.checkArgument(content != null && content != "", "content should not be null or empty");
- return new Notification3rd(title, content, channel_id, uri_activity, uri_action, badge_add_num,
+ return new Notification3rd(title, content, channel_id, uri_activity, uri_action, badge_add_num, badge_set_num,
badge_class, sound, extrasBuilder, numberExtrasBuilder, booleanExtrasBuilder, jsonExtrasBuilder);
}
}
diff --git a/src/main/java/cn/jpush/api/push/model/Options.java b/src/main/java/cn/jpush/api/push/model/Options.java
index f1208974..dfcae593 100644
--- a/src/main/java/cn/jpush/api/push/model/Options.java
+++ b/src/main/java/cn/jpush/api/push/model/Options.java
@@ -11,6 +11,22 @@
import java.util.Map;
import java.util.Set;
+/**
+ * 参考文档:https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push#options
+ *
+ * Options
+ *
+ *
+ * - sendno: 推送序号
+ * - time_to_live: 离线消息保留时长 (秒)
+ * - override_msg_id: 要覆盖的消息 ID
+ * - apns_production: APNs 是否生产环境
+ * - apns_collapse_id: 更新 iOS 通知的标识符
+ * - big_push_duration: 定速推送时长 (分钟)
+ * - third_party_channel: 推送请求下发通道
+ * - classification: 消息类型分类,极光不对指定的消息类型进行判断或校准,会以开发者自行指定的消息类型适配 Android 厂商通道。不填默认为 0
+ *
+ */
public class Options implements PushModel {
private static final String SENDNO = "sendno";
@@ -20,6 +36,7 @@ public class Options implements PushModel {
private static final String BIG_PUSH_DURATION = "big_push_duration";
private static final String APNS_COLLAPSE_ID = "apns_collapse_id";
private static final String THIRD_PARTH_CHANNEl = "third_party_channel";
+ private static final String CLASSIFICATION = "classification";
private static final long NONE_TIME_TO_LIVE = -1;
@@ -30,38 +47,12 @@ public class Options implements PushModel {
// minutes
private int bigPushDuration;
private String apnsCollapseId;
- private final Map customData;
-
-
+ private int classification;
/**
- * {
- * "third_party_channel":{
- * "xiaomi":{
- * "distribution":"ospush",
- * "channel_id":"*******"
- * },
- * "huawei":{
- * "distribution":"jpush"
- * },
- * "meizu":{
- * "distribution":"jpush"
- * },
- * "fcm":{
- * "distribution":"ospush"
- * },
- * "oppo":{
- * "distribution":"ospush",
- * "channel_id":"*******"
- * },
- * "vivo":{
- * "distribution":"ospush",
- * "classification":0 // 2020/06 新增,和vivo官方字段含义一致 0 代表运营消息,1 代表系统消息,不填vivo官方默认为0
- * // 使用此字段时,需使用setThirdPartyChannelV2方法,因为此值只能为整数形式
- * }
- * }
- * }
+ * 参考:https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push#third_party_channel-%E8%AF%B4%E6%98%8E
*/
private Map thirdPartyChannel;
+ private final Map customData;
private Options(int sendno,
long overrideMsgId,
@@ -69,6 +60,7 @@ private Options(int sendno,
boolean apnsProduction,
int bigPushDuration,
String apnsCollapseId,
+ int classification,
Map thirdPartyChannel,
Map customData) {
this.sendno = sendno;
@@ -77,6 +69,7 @@ private Options(int sendno,
this.apnsProduction = apnsProduction;
this.bigPushDuration = bigPushDuration;
this.apnsCollapseId = apnsCollapseId;
+ this.classification = classification;
this.thirdPartyChannel = thirdPartyChannel;
this.customData = customData;
}
@@ -132,6 +125,8 @@ public JsonElement toJSON() {
json.add(APNS_COLLAPSE_ID, new JsonPrimitive(apnsCollapseId));
}
+ json.add(CLASSIFICATION, new JsonPrimitive(classification));
+
if (null != thirdPartyChannel && thirdPartyChannel.size() > 0) {
JsonObject partyChannel = new JsonObject();
for (Map.Entry entry : thirdPartyChannel.entrySet()) {
@@ -158,6 +153,7 @@ public static class Builder {
private boolean apnsProduction = false;
private int bigPushDuration = 0;
private String apnsCollapseId;
+ private int classification;
private Map thirdPartyChannel;
private Map customData;
@@ -191,6 +187,11 @@ public Builder setBigPushDuration(int bigPushDuration) {
return this;
}
+ public Builder setClassification(int classification) {
+ this.classification = classification;
+ return this;
+ }
+
@Deprecated
public Map> getThirdPartyChannel() {
if (null != thirdPartyChannel) {
@@ -248,7 +249,7 @@ public Builder addCustom(Map extras) {
}
public Builder addCustom(String key, Number value) {
- Preconditions.checkArgument(! (null == key), "Key should not be null.");
+ Preconditions.checkArgument(!(null == key), "Key should not be null.");
if (customData == null) {
customData = new LinkedHashMap();
}
@@ -257,7 +258,7 @@ public Builder addCustom(String key, Number value) {
}
public Builder addCustom(String key, String value) {
- Preconditions.checkArgument(! (null == key), "Key should not be null.");
+ Preconditions.checkArgument(!(null == key), "Key should not be null.");
if (customData == null) {
customData = new LinkedHashMap();
}
@@ -266,7 +267,7 @@ public Builder addCustom(String key, String value) {
}
public Builder addCustom(String key, Boolean value) {
- Preconditions.checkArgument(! (null == key), "Key should not be null.");
+ Preconditions.checkArgument(!(null == key), "Key should not be null.");
if (customData == null) {
customData = new LinkedHashMap();
}
@@ -284,7 +285,7 @@ public Options build() {
sendno = ServiceHelper.generateSendno();
}
- return new Options(sendno, overrideMsgId, timeToLive, apnsProduction, bigPushDuration, apnsCollapseId, thirdPartyChannel, customData);
+ return new Options(sendno, overrideMsgId, timeToLive, apnsProduction, bigPushDuration, apnsCollapseId, classification, thirdPartyChannel, customData);
}
}
diff --git a/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java b/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java
index 65ad98ad..eefc1b80 100644
--- a/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java
+++ b/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java
@@ -14,23 +14,13 @@ public class LiveActivity implements PushModel {
private final String iOSEvent;
private final JsonObject iOSContentState;
- private final String iOSAlertTitle;
- private final String iOSAlertAlternateTitle;
- private final String iOSAlertBody;
- private final String iOSAlertAlternateBody;
- private final String iOSAlertSound;
- private final Integer iOSDismissalDate;
-
- public LiveActivity(Boolean apnsProduction, String liveActivityId, String iOSEvent, JsonObject iOSContentState, String iOSAlertTitle, String iOSAlertAlternateTitle, String iOSAlertBody, String iOSAlertAlternateBody, String iOSAlertSound, Integer iOSDismissalDate) {
+ private final Long iOSDismissalDate;
+
+ public LiveActivity(Boolean apnsProduction, String liveActivityId, String iOSEvent, JsonObject iOSContentState, Long iOSDismissalDate) {
this.apnsProduction = apnsProduction;
this.liveActivityId = liveActivityId;
this.iOSEvent = iOSEvent;
this.iOSContentState = iOSContentState;
- this.iOSAlertTitle = iOSAlertTitle;
- this.iOSAlertAlternateTitle = iOSAlertAlternateTitle;
- this.iOSAlertBody = iOSAlertBody;
- this.iOSAlertAlternateBody = iOSAlertAlternateBody;
- this.iOSAlertSound = iOSAlertSound;
this.iOSDismissalDate = iOSDismissalDate;
}
@@ -43,12 +33,7 @@ public static class Builder {
private String liveActivityId;
private String iOSEvent;
private JsonObject iOSContentState;
- private String iOSAlertTitle;
- private String iOSAlertAlternateTitle;
- private String iOSAlertBody;
- private String iOSAlertAlternateBody;
- private String iOSAlertSound;
- private Integer iOSDismissalDate;
+ private Long iOSDismissalDate;
public Builder apnsProduction(Boolean apnsProduction) {
this.apnsProduction = apnsProduction;
@@ -91,38 +76,13 @@ public Builder iOSContentState(String key, Boolean value) {
return this;
}
- public Builder iOSAlertTitle(String iOSAlertTitle) {
- this.iOSAlertTitle = iOSAlertTitle;
- return this;
- }
-
- public Builder iOSAlertAlternateTitle(String iOSAlertAlternateTitle) {
- this.iOSAlertAlternateTitle = iOSAlertAlternateTitle;
- return this;
- }
-
- public Builder iOSAlertBody(String iOSAlertBody) {
- this.iOSAlertBody = iOSAlertBody;
- return this;
- }
-
- public Builder iOSAlertAlternateBody(String iOSAlertAlternateBody) {
- this.iOSAlertAlternateBody = iOSAlertAlternateBody;
- return this;
- }
-
- public Builder iOSAlertSound(String iOSAlertSound) {
- this.iOSAlertSound = iOSAlertSound;
- return this;
- }
-
- public Builder iOSDismissalDate(Integer iOSDismissalDate) {
+ public Builder iOSDismissalDate(Long iOSDismissalDate) {
this.iOSDismissalDate = iOSDismissalDate;
return this;
}
public LiveActivity build() {
- return new LiveActivity(apnsProduction, liveActivityId, iOSEvent, iOSContentState, iOSAlertTitle, iOSAlertAlternateTitle, iOSAlertBody, iOSAlertAlternateBody, iOSAlertSound, iOSDismissalDate);
+ return new LiveActivity(apnsProduction, liveActivityId, iOSEvent, iOSContentState, iOSDismissalDate);
}
}
@@ -143,30 +103,11 @@ public JsonElement toJSON() {
if (apnsProduction != null) {
optionsJsonObject.addProperty("apns_production", apnsProduction);
}
- if (iOSAlertTitle != null || iOSAlertAlternateTitle != null || iOSAlertBody != null || iOSAlertAlternateBody != null || iOSAlertSound != null) {
- optionsJsonObject.addProperty("alternate_set", true);
- }
JsonObject liveActivityJsonObject = new JsonObject();
JsonObject iOSJsonObject = new JsonObject();
JsonObject alertJsonObject = new JsonObject();
- if (iOSAlertTitle != null) {
- alertJsonObject.addProperty("title", iOSAlertTitle);
- }
- if (iOSAlertAlternateTitle != null) {
- alertJsonObject.addProperty("alternate_title", iOSAlertAlternateTitle);
- }
- if (iOSAlertBody != null) {
- alertJsonObject.addProperty("body", iOSAlertBody);
- }
- if (iOSAlertAlternateBody != null) {
- alertJsonObject.addProperty("alternate_body", iOSAlertAlternateBody);
- }
- if (iOSAlertSound != null) {
- alertJsonObject.addProperty("sound", iOSAlertSound);
- }
-
if (iOSEvent != null) {
iOSJsonObject.addProperty("event", iOSEvent);
}
@@ -176,7 +117,7 @@ public JsonElement toJSON() {
if (!alertJsonObject.entrySet().isEmpty()) {
iOSJsonObject.add("alert", alertJsonObject);
}
- if (iOSDismissalDate != null) {
+ if (!alertJsonObject.entrySet().isEmpty()) {
iOSJsonObject.addProperty("dismissal-date", iOSDismissalDate);
}
diff --git a/src/main/java/cn/jpush/api/push/model/notification/IosNotification.java b/src/main/java/cn/jpush/api/push/model/notification/IosNotification.java
index 4e7cf7ca..c8c844af 100644
--- a/src/main/java/cn/jpush/api/push/model/notification/IosNotification.java
+++ b/src/main/java/cn/jpush/api/push/model/notification/IosNotification.java
@@ -14,13 +14,15 @@
* 支持 APNs 默认的几个参数:
*
* - alert: 继承自父类 PlatformNotification 的 alert 属性;本类设置则覆盖。
- * - badge: 支持 setBadge(int) 方法来设置;支持 incrBadge(int) 方法来增加。
* - sound: 支持 setSound(string) 方法来设置声音文件。或者 setSound(JSON object) 对应官方payload结构
+ * - badge: 支持 setBadge(int) 方法来设置;支持 incrBadge(int) 方法来增加。
* - content-available: 用来支持后台推送。如果该值赋值为 1,表示开启后台推送。
* - mutable-content: 通知扩展
* - category: IOS 8 才支持。设置 APNs payload 中的 "category" 字段值
* - mutable-content: 通知扩展
* - extras: JSON object. 支持更多的自定义字段信息。
+ * - thread-id: string. ios 的远程通知通过该属性来对通知进行分组,同一个 thread-id 的通知归为一组。
+ * - interruption-level: string. ios 15 的通知级别,取值只能是 active,critical,passive,time-sensitive 中的一个,详情参考:UNNotificationInterruptionLevel。
*
*
* 需要特别留意的是,JPush SDK 会对以下几个值有特别的默认设置考虑:
@@ -41,7 +43,8 @@ public class IosNotification extends PlatformNotification {
private static final String MUTABLE_CONTENT = "mutable-content";
private static final String CATEGORY = "category";
private static final String THREAD_ID = "thread-id";
-
+ private static final String INTERRUPTION_LEVEL = "interruption-level";
+
private static final String ALERT_VALID_BADGE = "Badge number should be 0~99999, "
+ "and can be prefixed with + to add, - to minus";
@@ -54,10 +57,11 @@ public class IosNotification extends PlatformNotification {
private final String category;
private final boolean mutableContent;
private final String threadId;
+ private final String interruptionLevel;
private IosNotification(Object alert, Object sound, String badge,
boolean contentAvailable, boolean soundDisabled, boolean badgeDisabled,
- String category, boolean mutableContent,String threadId,
+ String category, boolean mutableContent,String threadId,String interruptionLevel,
Map extras,
Map numberExtras,
Map booleanExtras,
@@ -73,6 +77,7 @@ private IosNotification(Object alert, Object sound, String badge,
this.category = category;
this.mutableContent = mutableContent;
this.threadId = threadId;
+ this.interruptionLevel = interruptionLevel;
}
public static Builder newBuilder() {
@@ -124,6 +129,9 @@ public JsonElement toJSON() {
if (null != threadId) {
json.add(THREAD_ID, new JsonPrimitive(threadId));
}
+ if (null != interruptionLevel) {
+ json.add(INTERRUPTION_LEVEL, new JsonPrimitive(interruptionLevel));
+ }
return json;
}
@@ -138,6 +146,7 @@ public static class Builder extends PlatformNotification.Builder