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 ;
@@ -55,6 +57,7 @@ public static void main(String[] args) {
5557// testSendPushes();
5658// testSendPush_fromJSON();
5759// testSendPushWithCallback();
60+ // testSendPushWithCid();
5861 }
5962
6063 // 使用 NettyHttpClient 异步接口发送请求
@@ -80,10 +83,13 @@ public void onSucceed(ResponseWrapper responseWrapper) {
8083 public static void testSendPush () {
8184 ClientConfig clientConfig = ClientConfig .getInstance ();
8285 final JPushClient jpushClient = new JPushClient (MASTER_SECRET , APP_KEY , null , clientConfig );
86+ // String authCode = ServiceHelper.getBasicAuthorization(APP_KEY, MASTER_SECRET);
8387 // Here you can use NativeHttpClient or NettyHttpClient or ApacheHttpClient.
8488 // Call setHttpClient to set httpClient,
8589 // If you don't invoke this method, default httpClient will use NativeHttpClient.
90+
8691// ApacheHttpClient httpClient = new ApacheHttpClient(authCode, null, clientConfig);
92+ // NettyHttpClient httpClient =new NettyHttpClient(authCode, null, clientConfig);
8793// jpushClient.getPushClient().setHttpClient(httpClient);
8894 final PushPayload payload = buildPushObject_android_and_ios ();
8995// // For push, all you need do is to build PushPayload object.
@@ -287,6 +293,7 @@ public static PushPayload buildPushObject_ios_tagAnd_alertWithExtrasAndMessage()
287293 .addPlatformNotification (IosNotification .newBuilder ()
288294 .setAlert (ALERT )
289295 .setBadge (5 )
296+ .setMutableContent (false )
290297 .setSound ("happy" )
291298 .addExtra ("from" , "JPush" )
292299 .build ())
@@ -351,9 +358,20 @@ public static PushPayload buildPushObject_all_tag_not() {
351358 }
352359
353360 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+
354371 return PushPayload .newBuilder ()
355372 .setPlatform (Platform .android ())
356- .setAudience (Audience .registrationId ("18071adc030dcba91c0" ))
373+ // .setAudience(Audience.registrationId("1507bfd3f79558957de"))
374+ .setAudience (Audience .registrationId (list ))
357375 .setNotification (Notification .alert (ALERT ))
358376 .setCid ("cid" )
359377 .build ();
@@ -408,7 +426,12 @@ public static void testSendIosAlert() {
408426 public static void testSendWithSMS () {
409427 JPushClient jpushClient = new JPushClient (MASTER_SECRET , APP_KEY );
410428 try {
411- 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 ();
412435 PushResult result = jpushClient .sendAndroidMessageWithAlias ("Test SMS" , "test sms" , sms , "alias1" );
413436 LOG .info ("Got result - " + result );
414437 } catch (APIConnectionException e ) {
0 commit comments