Skip to content

Commit 77ca447

Browse files
author
Javen
committed
Support badge +0. It is same effect of disableBadge()
1 parent 1b116fe commit 77ca447

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/cn/jpush/api/push/model/notification/IosNotification.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,7 @@ public Builder incrBadge(int badge) {
124124
return this;
125125
}
126126

127-
if (badge == 0) {
128-
LOG.warn("No action for incrBadge(0)");
129-
return this;
130-
131-
} else if (badge > 0) {
127+
if (badge >= 0) {
132128
this.badge = "+" + badge;
133129
} else {
134130
this.badge = "" + badge;

test/cn/jpush/api/push/model/notification/IosNotificationTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ public void testBadge_plus_2() {
6363
Assert.assertEquals("", json, ios.toJSON());
6464
}
6565

66+
@Test
67+
public void testBadge_plus_0() {
68+
IosNotification ios = IosNotification.newBuilder().incrBadge(0).build();
69+
JsonObject json = new JsonObject();
70+
json.add("badge", new JsonPrimitive("+0"));
71+
json.add("sound", new JsonPrimitive(""));
72+
Assert.assertEquals("", json, ios.toJSON());
73+
}
74+
6675
@Test
6776
public void testBadge_minus_2() {
6877
IosNotification ios = IosNotification.newBuilder().incrBadge(-2).build();

0 commit comments

Comments
 (0)