Skip to content

Commit 468184f

Browse files
author
huanglh
committed
TS-6286 修复alert_type字段问题
1 parent 75ec045 commit 468184f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public JsonElement toJSON() {
193193
json.add(STYLE, new JsonPrimitive(this.style));
194194
}
195195

196-
if (-1 != alert_type) {
196+
if (-1 != alert_type && alert_type <= 7) {
197197
json.add(ALERT_TYPE, new JsonPrimitive(this.alert_type));
198198
}
199199

src/test/java/cn/jpush/api/push/PushClientTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,19 @@ private static PushPayload buildPushObject_android_cid() {
216216
.build();
217217
}
218218

219+
@Test
220+
public void testAlertType(){
221+
Notification notification = Notification.newBuilder()
222+
.addPlatformNotification(AndroidNotification.newBuilder()
223+
.setAlert("android内容")
224+
.setTitle("android标题")
225+
.setAlertType(-1)
226+
.addCustom("uri_activity","uri_activity")
227+
.addCustom("uri_action","uri_action")
228+
.addExtra("a","a")
229+
.build()
230+
).build();
231+
System.out.println(notification.toJSON());
232+
}
233+
219234
}

0 commit comments

Comments
 (0)