Skip to content

Commit 48578be

Browse files
author
wicked_tc130
committed
update version to 3.7.7.
1 parent 41d9ef8 commit 48578be

14 files changed

+263
-202
lines changed

pom.xml

+2-2
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.7.6</version>
6+
<version>3.7.7</version>
77
<packaging>jar</packaging>
88
<url>https://github.com/jpush/jpush-api-java-client</url>
99
<name>JPush API Java Client</name>
@@ -51,7 +51,7 @@
5151
<dependency>
5252
<groupId>cn.jpush.api</groupId>
5353
<artifactId>jiguang-common</artifactId>
54-
<version>1.2.6</version>
54+
<version>1.2.7</version>
5555
</dependency>
5656
<dependency>
5757
<groupId>org.apache.httpcomponents</groupId>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* 使用说明
1515
* notification_3rd 只针对开通了厂商通道的用户生效;
1616
* notification 和 notification_3rd 不能同时有内容,如果这两块同时有内容,则会返回错误提示;
17-
* notification_3rd 的内容对 iOS 和 WinPhone 平台无效,只针对 Android 平台生效;
17+
* notification_3rd 的内容对 iOS 和 HMOS 平台无效,只针对 Android 平台生效;
1818
* notification_3rd 是用作补发厂商通知的内容,只有当 message 部分有内容,才允许传递此字段,且要两者都不为空时,才会对离线的厂商设备转发厂商通道的通知。
1919
*/
2020
public class Notification3rd implements PushModel{

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

+15-15
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#platform
1414
*
15-
* JPush 当前支持 Android, iOS, QuickApp,Windows Phone 四个平台的推送。其关键字分别为:"android", "ios", "quickapp","winphone"。
15+
* JPush 当前支持 Android, iOS, QuickApp, HMOS 四个平台的推送。其关键字分别为:"android", "ios", "quickapp","hmos"。
1616
* 使用方法,只需要在PushPayload中调用setPlatform方法。如:setPlatform(Platform.android_ios())
1717
* 如需要全平台推送,只需要setPlatform(Platform.all())
1818
*/
@@ -47,8 +47,8 @@ public static Platform quickapp() {
4747
return newBuilder().addDeviceType(DeviceType.QuickApp).build();
4848
}
4949

50-
public static Platform winphone() {
51-
return newBuilder().addDeviceType(DeviceType.WinPhone).build();
50+
public static Platform hmos() {
51+
return newBuilder().addDeviceType(DeviceType.HMOS).build();
5252
}
5353

5454
public static Platform android_ios() {
@@ -58,17 +58,17 @@ public static Platform android_ios() {
5858
.build();
5959
}
6060

61-
public static Platform android_winphone() {
61+
public static Platform android_hmos() {
6262
return newBuilder()
6363
.addDeviceType(DeviceType.Android)
64-
.addDeviceType(DeviceType.WinPhone)
64+
.addDeviceType(DeviceType.HMOS)
6565
.build();
6666
}
6767

68-
public static Platform ios_winphone() {
68+
public static Platform ios_hmos() {
6969
return newBuilder()
7070
.addDeviceType(DeviceType.IOS)
71-
.addDeviceType(DeviceType.WinPhone)
71+
.addDeviceType(DeviceType.HMOS)
7272
.build();
7373
}
7474

@@ -86,10 +86,10 @@ public static Platform ios_quickapp() {
8686
.build();
8787
}
8888

89-
public static Platform quickapp_winphone() {
89+
public static Platform quickapp_hmos() {
9090
return newBuilder()
9191
.addDeviceType(DeviceType.QuickApp)
92-
.addDeviceType(DeviceType.WinPhone)
92+
.addDeviceType(DeviceType.HMOS)
9393
.build();
9494
}
9595

@@ -101,27 +101,27 @@ public static Platform android_ios_quickapp() {
101101
.build();
102102
}
103103

104-
public static Platform android_ios_winphone() {
104+
public static Platform android_ios_hmos() {
105105
return newBuilder()
106106
.addDeviceType(DeviceType.Android)
107107
.addDeviceType(DeviceType.IOS)
108-
.addDeviceType(DeviceType.WinPhone)
108+
.addDeviceType(DeviceType.HMOS)
109109
.build();
110110
}
111111

112-
public static Platform android_quickapp_winphone() {
112+
public static Platform android_quickapp_hmos() {
113113
return newBuilder()
114114
.addDeviceType(DeviceType.Android)
115115
.addDeviceType(DeviceType.QuickApp)
116-
.addDeviceType(DeviceType.WinPhone)
116+
.addDeviceType(DeviceType.HMOS)
117117
.build();
118118
}
119119

120-
public static Platform ios_quickapp_winphone() {
120+
public static Platform ios_quickapp_hmos() {
121121
return newBuilder()
122122
.addDeviceType(DeviceType.IOS)
123123
.addDeviceType(DeviceType.QuickApp)
124-
.addDeviceType(DeviceType.WinPhone)
124+
.addDeviceType(DeviceType.HMOS)
125125
.build();
126126
}
127127

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
package cn.jpush.api.push.model.notification;
2+
3+
import com.google.gson.JsonElement;
4+
import com.google.gson.JsonObject;
5+
import com.google.gson.JsonPrimitive;
6+
7+
import java.util.Map;
8+
9+
/**
10+
* <p><b>HMOS Phone 通知类</b></p>
11+
* <br>
12+
* 具体使用方法请参考官方文档 https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#platform
13+
* 支持 HMOS Notification 的参数:
14+
* <ul>
15+
* <li>alert: 继承自父类 PlatformNotification 的 alert 属性;本类设置则覆盖。</li>
16+
* <li>title: 支持 setTitle(string) 方法来设置;可替换通知标题。 </li>
17+
* <li>_open_page: 支持 setOpenPage(String) 方法来设置;可设置点击打开的页面名称</li>
18+
* <li>extras: 继承自父类 PlatformNotification 的 extras 属性;支持通过 addExtra(key, value) 来添加自定义字段,具体看代码。 </li>
19+
* </ul>
20+
* <br>
21+
*/
22+
public class HmosNotification extends PlatformNotification {
23+
private static final String NOTIFICATION_HMOS = "hmos";
24+
25+
private static final String TITLE = "title";
26+
private static final String CATEGORY = "category";
27+
private static final String LARGE_ICON = "large_icon";
28+
private static final String INTENT = "intent";
29+
private static final String BADGE_ADD_NUM = "badge_add_num";
30+
private static final String TEST_MESSAGE = "test_message";
31+
private static final String RECEIPT_ID = "receipt_id";
32+
33+
private final String title;
34+
private final String category;
35+
private final String large_icon;
36+
private final JsonObject intent;
37+
private final Integer badge_add_num;
38+
private final Boolean test_message;
39+
private final String receipt_id;
40+
41+
private HmosNotification(Object alert,
42+
String title,
43+
String category,
44+
String large_icon,
45+
JsonObject intent,
46+
Integer badge_add_num,
47+
Boolean test_message,
48+
String receipt_id,
49+
Map<String, String> extras,
50+
Map<String, Number> numberExtras,
51+
Map<String, Boolean> booleanExtras,
52+
Map<String, JsonObject> jsonExtras,
53+
Map<String, JsonPrimitive> customData) {
54+
super(alert, extras, numberExtras, booleanExtras, jsonExtras, customData);
55+
56+
this.title = title;
57+
this.category = category;
58+
this.large_icon = large_icon;
59+
this.intent = intent;
60+
this.badge_add_num = badge_add_num;
61+
this.test_message = test_message;
62+
this.receipt_id = receipt_id;
63+
}
64+
65+
public static Builder newBuilder() {
66+
return new Builder();
67+
}
68+
69+
public static HmosNotification alert(String alert) {
70+
return newBuilder().setAlert(alert).build();
71+
}
72+
73+
74+
@Override
75+
public String getPlatform() {
76+
return NOTIFICATION_HMOS;
77+
}
78+
79+
@Override
80+
public JsonElement toJSON() {
81+
JsonObject json = super.toJSON().getAsJsonObject();
82+
83+
if (null != title) {
84+
json.add(TITLE, new JsonPrimitive(title));
85+
}
86+
if (null != category) {
87+
json.add(CATEGORY, new JsonPrimitive(category));
88+
}
89+
if (null != large_icon) {
90+
json.add(LARGE_ICON, new JsonPrimitive(large_icon));
91+
}
92+
if (null != intent) {
93+
json.add(INTENT, intent);
94+
}
95+
if (null != badge_add_num) {
96+
json.add(BADGE_ADD_NUM, new JsonPrimitive(badge_add_num));
97+
}
98+
if (null != test_message) {
99+
json.add(TEST_MESSAGE, new JsonPrimitive(test_message));
100+
}
101+
if (null != receipt_id) {
102+
json.add(RECEIPT_ID, new JsonPrimitive(receipt_id));
103+
}
104+
return json;
105+
}
106+
107+
108+
public static class Builder extends PlatformNotification.Builder<HmosNotification, Builder> {
109+
private String title;
110+
private String category;
111+
private String large_icon;
112+
private JsonObject intent;
113+
private Integer badge_add_num;
114+
private Boolean test_message;
115+
private String receipt_id;
116+
117+
@Override
118+
protected Builder getThis() {
119+
return this;
120+
}
121+
122+
@Override
123+
public Builder setAlert(Object alert) {
124+
this.alert = alert;
125+
return this;
126+
}
127+
128+
public Builder setTitle(String title) {
129+
this.title = title;
130+
return this;
131+
}
132+
133+
public Builder setCategory(String category) {
134+
this.category = category;
135+
return this;
136+
}
137+
138+
public Builder setLarge_icon(String large_icon) {
139+
this.large_icon = large_icon;
140+
return this;
141+
}
142+
143+
public Builder setIntent(JsonObject intent) {
144+
this.intent = intent;
145+
return this;
146+
}
147+
148+
public Builder setBadge_add_num(Integer badge_add_num) {
149+
this.badge_add_num = badge_add_num;
150+
return this;
151+
}
152+
153+
public Builder setTest_message(Boolean test_message) {
154+
this.test_message = test_message;
155+
return this;
156+
}
157+
158+
public Builder setReceipt_id(String receipt_id) {
159+
this.receipt_id = receipt_id;
160+
return this;
161+
}
162+
163+
public HmosNotification build() {
164+
return new HmosNotification(alert, title, category,large_icon,intent,badge_add_num,test_message,receipt_id,
165+
extrasBuilder, numberExtrasBuilder, booleanExtrasBuilder, jsonExtrasBuilder, super.customData);
166+
}
167+
}
168+
}

src/main/java/cn/jpush/api/push/model/notification/Notification.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ public static Notification ios_incr_badge(int badge) {
9999
.build();
100100
}
101101

102-
public static Notification winphone(String alert, Map<String, String> extras) {
102+
public static Notification hmos(String alert, String title, Map<String, String> extras) {
103103
return newBuilder()
104-
.addPlatformNotification(WinphoneNotification.newBuilder()
104+
.addPlatformNotification(HmosNotification.newBuilder()
105105
.setAlert(alert)
106+
.setTitle(title)
106107
.addExtras(extras)
107108
.build())
108109
.build();

0 commit comments

Comments
 (0)