@@ -18,31 +18,48 @@ public class JPushClientExample {
18
18
protected static final Logger LOG = LoggerFactory .getLogger (JPushClientExample .class );
19
19
20
20
// 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";
23
23
24
24
public static final String msgTitle = "Test from API example" ;
25
25
public static final String msgContent = "Test Test" ;
26
- public static final String registrationID = "0900e8d85ef " ;
26
+ public static final String registrationID = "092923191f1 " ;
27
27
public static final String tag = "tag_api" ;
28
28
29
29
public static void main (String [] args ) {
30
- testSend ();
30
+ // testSend();
31
31
testSendMpnsNotificaiton ();
32
- testGetReport ();
32
+ // testGetReport();
33
33
}
34
34
35
35
private static void testSendMpnsNotificaiton () {
36
36
JPushClient jpushClient = new JPushClient (masterSecret , appKey , 0 , DeviceEnum .MPNS , false );
37
37
NotificationParams params = new NotificationParams ();
38
- params .setReceiverType (ReceiverTypeEnum .TAG );
39
- params .setReceiverValue (tag );
38
+ params .setReceiverType (ReceiverTypeEnum .REGISTRATION_ID );
39
+ params .setReceiverValue (registrationID );
40
40
params .setMpnsNotificationTitle (msgTitle );
41
41
42
42
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" );
44
46
45
47
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
+ }
46
63
}
47
64
48
65
private static void testSend () {
0 commit comments