Skip to content

Commit cdd425e

Browse files
author
Javen
committed
Test winphone platform push notificaiton.
1 parent 8ce4527 commit cdd425e

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

src/cn/jpush/api/common/DeviceEnum.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public enum DeviceEnum {
44

55
Android("android"),
66
IOS("ios"),
7-
MPNS("mpns");
7+
MPNS("winphone");
88

99
private final String value;
1010

src/cn/jpush/api/examples/JPushClientExample.java

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,48 @@ public class JPushClientExample {
1818
protected static final Logger LOG = LoggerFactory.getLogger(JPushClientExample.class);
1919

2020
// demo App defined in resources/jpush-api.conf
21-
private static final String appKey ="dd1066407b044738b6479275";
22-
private static final String masterSecret = "2b38ce69b1de2a7fa95706ea";
21+
private static final String appKey = "82d5658a74e76241f402d4a4"; //"dd1066407b044738b6479275";
22+
private static final String masterSecret = "451f2e305b6a9f523b3d015c"; //"2b38ce69b1de2a7fa95706ea";
2323

2424
public static final String msgTitle = "Test from API example";
2525
public static final String msgContent = "Test Test";
26-
public static final String registrationID = "0900e8d85ef";
26+
public static final String registrationID = "092923191f1";
2727
public static final String tag = "tag_api";
2828

2929
public static void main(String[] args) {
30-
testSend();
30+
// testSend();
3131
testSendMpnsNotificaiton();
32-
testGetReport();
32+
// testGetReport();
3333
}
3434

3535
private static void testSendMpnsNotificaiton() {
3636
JPushClient jpushClient = new JPushClient(masterSecret, appKey, 0, DeviceEnum.MPNS, false);
3737
NotificationParams params = new NotificationParams();
38-
params.setReceiverType(ReceiverTypeEnum.TAG);
39-
params.setReceiverValue(tag);
38+
params.setReceiverType(ReceiverTypeEnum.REGISTRATION_ID);
39+
params.setReceiverValue(registrationID);
4040
params.setMpnsNotificationTitle(msgTitle);
4141

4242
Map<String, Object> extras = new HashMap<String, Object>();
43-
extras.put(NotificationParams.MPNS_EXTRA_OPEN_PAGE, "MainPage.xaml");
43+
extras.put(NotificationParams.MPNS_EXTRA_OPEN_PAGE, "/MainPage.xaml");
44+
extras.put("key1", "value1");
45+
extras.put("key2", "value2");
4446

4547
MessageResult msgResult = jpushClient.sendNotification(msgContent, params, extras);
48+
if (msgResult.isResultOK()) {
49+
LOG.info("msgResult - " + msgResult);
50+
LOG.info("messageId - " + msgResult.getMessageId());
51+
} else {
52+
if (msgResult.getErrorCode() > 0) {
53+
// 业务异常
54+
LOG.warn("Service error - ErrorCode: "
55+
+ msgResult.getErrorCode() + ", ErrorMessage: "
56+
+ msgResult.getErrorMessage());
57+
} else {
58+
// 未到达 JPush
59+
LOG.error("Other excepitons - "
60+
+ msgResult.responseResult.exceptionString);
61+
}
62+
}
4663
}
4764

4865
private static void testSend() {

0 commit comments

Comments
 (0)