44import org .slf4j .LoggerFactory ;
55
66import cn .jpush .api .JPushClient ;
7+ import cn .jpush .api .common .resp .APIConnectionException ;
8+ import cn .jpush .api .common .resp .APIRequestException ;
9+ import cn .jpush .api .device .TagAliasResult ;
710
811public class DevcieExample {
912 protected static final Logger LOG = LoggerFactory .getLogger (DevcieExample .class );
@@ -16,9 +19,30 @@ public class DevcieExample {
1619 private static final String REGISTRATION_ID1 = "0900e8d85ef" ;
1720 private static final String REGISTRATION_ID2 = "0a04ad7d8b4" ;
1821
19- private static JPushClient jpushClient = new JPushClient (masterSecret , appKey , 3 );
20-
22+ private static JPushClient jpushClient = new JPushClient (masterSecret , appKey );
23+
2124 public static void main (String [] args ) {
22-
25+ testGetDeviceTagAlias ();
26+ }
27+
28+ public static void testGetDeviceTagAlias () {
29+ try {
30+ TagAliasResult result = jpushClient .getDeviceTagAlias (REGISTRATION_ID1 );
31+
32+ LOG .info (result .alias );
33+ LOG .info (result .tags .toString ());
34+
35+ } catch (APIConnectionException e ) {
36+ LOG .error ("Connection error. Should retry later. " , e );
37+
38+ } catch (APIRequestException e ) {
39+ LOG .error ("Error response from JPush server. Should review and fix it. " , e );
40+ LOG .info ("HTTP Status: " + e .getStatus ());
41+ LOG .info ("Error Code: " + e .getErrorCode ());
42+ LOG .info ("Error Message: " + e .getErrorMessage ());
43+ }
2344 }
45+
2446}
47+
48+
0 commit comments