22
33import java .net .URI ;
44import java .net .URISyntaxException ;
5+ import java .util .Collection ;
56import java .util .HashMap ;
7+ import java .util .LinkedList ;
68import java .util .Map ;
79
810import cn .jiguang .common .ServiceHelper ;
@@ -50,12 +52,12 @@ public class PushExample {
5052 public static void main (String [] args ) {
5153// testSendPushWithCustomConfig();
5254// testSendIosAlert();
53- // testSendPush();
55+ testSendPush ();
5456// testGetCidList();
5557// testSendPushes();
5658// testSendPush_fromJSON();
5759// testSendPushWithCallback();
58- testSendPushWithCid ();
60+ // testSendPushWithCid();
5961 }
6062
6163 // 使用 NettyHttpClient 异步接口发送请求
@@ -81,10 +83,13 @@ public void onSucceed(ResponseWrapper responseWrapper) {
8183 public static void testSendPush () {
8284 ClientConfig clientConfig = ClientConfig .getInstance ();
8385 final JPushClient jpushClient = new JPushClient (MASTER_SECRET , APP_KEY , null , clientConfig );
86+ // String authCode = ServiceHelper.getBasicAuthorization(APP_KEY, MASTER_SECRET);
8487 // Here you can use NativeHttpClient or NettyHttpClient or ApacheHttpClient.
8588 // Call setHttpClient to set httpClient,
8689 // If you don't invoke this method, default httpClient will use NativeHttpClient.
90+
8791// ApacheHttpClient httpClient = new ApacheHttpClient(authCode, null, clientConfig);
92+ // NettyHttpClient httpClient =new NettyHttpClient(authCode, null, clientConfig);
8893// jpushClient.getPushClient().setHttpClient(httpClient);
8994 final PushPayload payload = buildPushObject_android_and_ios ();
9095// // For push, all you need do is to build PushPayload object.
@@ -288,6 +293,7 @@ public static PushPayload buildPushObject_ios_tagAnd_alertWithExtrasAndMessage()
288293 .addPlatformNotification (IosNotification .newBuilder ()
289294 .setAlert (ALERT )
290295 .setBadge (5 )
296+ .setMutableContent (false )
291297 .setSound ("happy" )
292298 .addExtra ("from" , "JPush" )
293299 .build ())
@@ -352,9 +358,20 @@ public static PushPayload buildPushObject_all_tag_not() {
352358 }
353359
354360 public static PushPayload buildPushObject_android_cid () {
361+ Collection <String > list =new LinkedList <String >();
362+ list .add ("1507bfd3f79558957de" );
363+ list .add ("1507bfd3f79554957de" );
364+ list .add ("1507bfd3f79555957de" );
365+ list .add ("1507bfd3f79556957de" );
366+ list .add ("1507ffd3f79545957de" );
367+ list .add ("1507ffd3f79457957de" );
368+ list .add ("1507ffd3f79456757de" );
369+
370+
355371 return PushPayload .newBuilder ()
356372 .setPlatform (Platform .android ())
357- .setAudience (Audience .registrationId ("1507bfd3f79558957de" ))
373+ // .setAudience(Audience.registrationId("1507bfd3f79558957de"))
374+ .setAudience (Audience .registrationId (list ))
358375 .setNotification (Notification .alert (ALERT ))
359376 .setCid ("cid" )
360377 .build ();
@@ -409,7 +426,12 @@ public static void testSendIosAlert() {
409426 public static void testSendWithSMS () {
410427 JPushClient jpushClient = new JPushClient (MASTER_SECRET , APP_KEY );
411428 try {
412- SMS sms = SMS .content (1 , 10 );
429+ // SMS sms = SMS.content(1, 10);
430+ SMS sms = SMS .newBuilder ()
431+ .setDelayTime (1000 )
432+ .setTempID (2000 )
433+ .addPara ("Test" , 1 )
434+ .build ();
413435 PushResult result = jpushClient .sendAndroidMessageWithAlias ("Test SMS" , "test sms" , sms , "alias1" );
414436 LOG .info ("Got result - " + result );
415437 } catch (APIConnectionException e ) {
0 commit comments