|
34 | 34 | ### 依赖包 |
35 | 35 | * [slf4j](http://www.slf4j.org/) / log4j (Logger) |
36 | 36 | * [gson](https://code.google.com/p/google-gson/) (Google JSON Utils) |
37 | | -* [guava](https://code.google.com/p/guava-libraries/) (Google Java Utils) |
38 | 37 |
|
39 | 38 | > 其中 slf4j 可以与 logback, log4j, commons-logging 等日志框架一起工作,可根据你的需要配置使用。 |
40 | 39 |
|
|
85 | 84 |
|
86 | 85 | ### 推送样例 |
87 | 86 |
|
88 | | -> 以下片断来自项目代码里的文件:cn.jpush.api.examples.PushExample |
| 87 | +> 以下片断来自项目代码里的文件:example / cn.jpush.api.examples.PushExample |
89 | 88 |
|
90 | 89 | ``` |
91 | 90 | JPushClient jpushClient = new JPushClient(masterSecret, appKey, 3); |
|
188 | 187 |
|
189 | 188 | ### 统计获取样例 |
190 | 189 |
|
191 | | -> 以下片断来自项目代码里的文件:cn.jpush.api.examples.ReportsExample |
| 190 | +> 以下片断来自项目代码里的文件:example / cn.jpush.api.examples.ReportsExample |
192 | 191 |
|
193 | 192 | ``` |
194 | 193 | JPushClient jpushClient = new JPushClient(masterSecret, appKey); |
195 | | - try { |
| 194 | + try { |
196 | 195 | ReceivedsResult result = jpushClient.getReportReceiveds("1942377665"); |
197 | 196 | LOG.debug("Got result - " + result); |
198 | 197 | |
|
208 | 207 | LOG.info("Error Message: " + e.getErrorMessage()); |
209 | 208 | } |
210 | 209 | ``` |
| 210 | + |
| 211 | +### Tag/Alias 样例 |
| 212 | + |
| 213 | +> 以下片断来自项目代码里的文件:example / cn.jpush.api.examples.DeviceExample |
| 214 | +
|
| 215 | +``` |
| 216 | + try { |
| 217 | + TagAliasResult result = jpushClient.getDeviceTagAlias(REGISTRATION_ID1); |
| 218 | + |
| 219 | + LOG.info(result.alias); |
| 220 | + LOG.info(result.tags.toString()); |
| 221 | + |
| 222 | + } catch (APIConnectionException e) { |
| 223 | + LOG.error("Connection error. Should retry later. ", e); |
| 224 | + |
| 225 | + } catch (APIRequestException e) { |
| 226 | + LOG.error("Error response from JPush server. Should review and fix it. ", e); |
| 227 | + LOG.info("HTTP Status: " + e.getStatus()); |
| 228 | + LOG.info("Error Code: " + e.getErrorCode()); |
| 229 | + LOG.info("Error Message: " + e.getErrorMessage()); |
| 230 | + } |
| 231 | +``` |
| 232 | + |
0 commit comments