|
1 | 1 | package cn.jpush.api.examples; |
2 | 2 |
|
| 3 | +import java.util.HashSet; |
3 | 4 | import java.util.Map; |
4 | 5 |
|
5 | 6 | import org.slf4j.Logger; |
|
15 | 16 | public class DeviceExample { |
16 | 17 | protected static final Logger LOG = LoggerFactory.getLogger(DeviceExample.class); |
17 | 18 |
|
18 | | - private static final String appKey = "dd1066407b044738b6479275"; |
19 | | - private static final String masterSecret = "e8cc9a76d5b7a580859bcfa7"; |
| 19 | + private static final String appKey = "7b4b94cca0d185d611e53cca"; |
| 20 | + private static final String masterSecret = "860803cf613ed54aa3b941a8"; |
20 | 21 | private static final String TAG1 = "tag1"; |
21 | 22 | private static final String ALIAS1 = "alias1"; |
22 | 23 | private static final String ALIAS2 = "alias2"; |
23 | | - private static final String REGISTRATION_ID1 = "0900e8d85ef"; |
| 24 | + private static final String REGISTRATION_ID1 = "160a3797c856951a397"; |
24 | 25 | private static final String REGISTRATION_ID2 = "0a04ad7d8b4"; |
25 | 26 |
|
26 | 27 | private static JPushClient jpushClient = new JPushClient(masterSecret, appKey); |
27 | 28 |
|
28 | 29 | public static void main(String[] args) { |
29 | | - testGetDeviceTagAlias(); |
| 30 | +// testGetDeviceTagAlias(); |
30 | 31 | // testGetUserOnlineStatus(); |
| 32 | + testUpdateDeviceTagAlias(); |
| 33 | + } |
| 34 | + |
| 35 | + public static void testUpdateDeviceTagAlias() { |
| 36 | + HashSet<String> tagSet = new HashSet<String>(); |
| 37 | + tagSet.add("hhh"); |
| 38 | + try { |
| 39 | + DefaultResult result = jpushClient.updateDeviceTagAlias(REGISTRATION_ID1, null, tagSet, null); |
| 40 | + LOG.info("Got result " + result); |
| 41 | + } catch (APIConnectionException e) { |
| 42 | + LOG.error("Connection error. Should retry later. ", e); |
| 43 | + |
| 44 | + } catch (APIRequestException e) { |
| 45 | + LOG.error("Error response from JPush server. Should review and fix it. ", e); |
| 46 | + LOG.info("HTTP Status: " + e.getStatus()); |
| 47 | + LOG.info("Error Code: " + e.getErrorCode()); |
| 48 | + LOG.info("Error Message: " + e.getErrorMessage()); |
| 49 | + } |
31 | 50 | } |
32 | 51 |
|
33 | 52 | public static void testGetDeviceTagAlias() { |
|
0 commit comments