Skip to content

Commit 1ff9738

Browse files
author
Javen
committed
Changed to mpns notification.
1 parent 5aed130 commit 1ff9738

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

src/cn/jpush/api/push/model/notification/WinPhoneNotification.java renamed to src/cn/jpush/api/push/model/notification/MpnsNotification.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import com.google.gson.JsonObject;
99
import com.google.gson.JsonPrimitive;
1010

11-
public class WinPhoneNotification extends PlatformNotification {
12-
public static final String NOTIFICATION_WINPHONE = "winphone";
11+
public class MpnsNotification extends PlatformNotification {
12+
public static final String NOTIFICATION_MPNS = "mpns";
1313

1414
public static final String TITLE = "title";
1515
public static final String EXTRAS = "extras";
@@ -19,7 +19,7 @@ public class WinPhoneNotification extends PlatformNotification {
1919
private final String openPage;
2020
private final ImmutableMap<String, String> extras;
2121

22-
private WinPhoneNotification(String alert, String title, String openPage,
22+
private MpnsNotification(String alert, String title, String openPage,
2323
ImmutableMap<String, String> extras) {
2424
super(alert);
2525
this.title = title;
@@ -31,14 +31,14 @@ public static Builder newBuilder() {
3131
return new Builder();
3232
}
3333

34-
public static WinPhoneNotification alert(String alert) {
34+
public static MpnsNotification alert(String alert) {
3535
return newBuilder().setAlert(alert).build();
3636
}
3737

3838

3939
@Override
4040
public String getPlatform() {
41-
return NOTIFICATION_WINPHONE;
41+
return NOTIFICATION_MPNS;
4242
}
4343

4444
@Override
@@ -106,8 +106,8 @@ public Builder addExtra(String key, String value) {
106106
return this;
107107
}
108108

109-
public WinPhoneNotification build() {
110-
return new WinPhoneNotification(alert, title, openPage,
109+
public MpnsNotification build() {
110+
return new MpnsNotification(alert, title, openPage,
111111
(null == extrasBuilder) ? null : extrasBuilder.build());
112112
}
113113
}

test/cn/jpush/api/push/model/notification/WinPhoneNotificationTests.java renamed to test/cn/jpush/api/push/model/notification/MpnsNotificationTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,33 @@
66
import com.google.gson.JsonObject;
77
import com.google.gson.JsonPrimitive;
88

9-
public class WinPhoneNotificationTests {
9+
public class MpnsNotificationTests {
1010

1111
@Test(expected = IllegalArgumentException.class)
1212
public void testIllegal() {
13-
WinPhoneNotification mpns = WinPhoneNotification.newBuilder().build();
13+
MpnsNotification mpns = MpnsNotification.newBuilder().build();
1414
Assert.assertEquals("", "", mpns.toJSON());
1515
}
1616

1717
@Test
1818
public void testQuickAlert() {
19-
WinPhoneNotification mpns = WinPhoneNotification.alert("aaa");
19+
MpnsNotification mpns = MpnsNotification.alert("aaa");
2020
JsonObject json = new JsonObject();
2121
json.add("alert", new JsonPrimitive("aaa"));
2222
Assert.assertEquals("", json, mpns.toJSON());
2323
}
2424

2525
@Test
2626
public void testTitle() {
27-
WinPhoneNotification mpns = WinPhoneNotification.newBuilder().setTitle("title").build();
27+
MpnsNotification mpns = MpnsNotification.newBuilder().setTitle("title").build();
2828
JsonObject json = new JsonObject();
2929
json.add("title", new JsonPrimitive("title"));
3030
Assert.assertEquals("", json, mpns.toJSON());
3131
}
3232

3333
@Test
3434
public void testExtra() {
35-
WinPhoneNotification mpns = WinPhoneNotification.newBuilder().addExtra("key", "value").build();
35+
MpnsNotification mpns = MpnsNotification.newBuilder().addExtra("key", "value").build();
3636
JsonObject json = new JsonObject();
3737
JsonObject extra = new JsonObject();
3838
extra.add("key", new JsonPrimitive("value"));

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void testIllegal() {
2121
.build();
2222
Assert.assertEquals("", "", notification.toJSON());
2323
}
24-
24+
2525
@Test
2626
public void testAlertAndroid() {
2727
Notification notification = Notification.newBuilder()
@@ -34,6 +34,31 @@ public void testAlertAndroid() {
3434
Assert.assertEquals("", json, notification.toJSON());
3535
}
3636

37+
@Test
38+
public void testAlertIos() {
39+
Notification notification = Notification.newBuilder()
40+
.addPlatformNotification(IosNotification.alert("alert"))
41+
.build();
42+
JsonObject json = new JsonObject();
43+
JsonObject ios = new JsonObject();
44+
ios.add("alert", new JsonPrimitive("alert"));
45+
ios.add("sound", new JsonPrimitive(""));
46+
json.add("ios", ios);
47+
Assert.assertEquals("", json, notification.toJSON());
48+
}
49+
50+
@Test
51+
public void testAlertMpns() {
52+
Notification notification = Notification.newBuilder()
53+
.addPlatformNotification(MpnsNotification.alert("alert"))
54+
.build();
55+
JsonObject json = new JsonObject();
56+
JsonObject mpns = new JsonObject();
57+
mpns.add("alert", new JsonPrimitive("alert"));
58+
json.add("mpns", mpns);
59+
Assert.assertEquals("", json, notification.toJSON());
60+
}
61+
3762
@Test
3863
public void testAlertAll() {
3964
Notification notification = Notification.alert("alert");

0 commit comments

Comments
 (0)