Skip to content

Commit d9fc617

Browse files
author
Javen Fang
committed
Update README.md
Add device example
1 parent e6595c7 commit d9fc617

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
### 依赖包
3535
* [slf4j](http://www.slf4j.org/) / log4j (Logger)
3636
* [gson](https://code.google.com/p/google-gson/) (Google JSON Utils)
37-
* [guava](https://code.google.com/p/guava-libraries/) (Google Java Utils)
3837

3938
> 其中 slf4j 可以与 logback, log4j, commons-logging 等日志框架一起工作,可根据你的需要配置使用。
4039
@@ -85,7 +84,7 @@
8584

8685
### 推送样例
8786

88-
> 以下片断来自项目代码里的文件:cn.jpush.api.examples.PushExample
87+
> 以下片断来自项目代码里的文件:example / cn.jpush.api.examples.PushExample
8988
9089
```
9190
JPushClient jpushClient = new JPushClient(masterSecret, appKey, 3);
@@ -188,11 +187,11 @@
188187

189188
### 统计获取样例
190189

191-
> 以下片断来自项目代码里的文件:cn.jpush.api.examples.ReportsExample
190+
> 以下片断来自项目代码里的文件:example / cn.jpush.api.examples.ReportsExample
192191
193192
```
194193
JPushClient jpushClient = new JPushClient(masterSecret, appKey);
195-
try {
194+
try {
196195
ReceivedsResult result = jpushClient.getReportReceiveds("1942377665");
197196
LOG.debug("Got result - " + result);
198197
@@ -208,3 +207,26 @@
208207
LOG.info("Error Message: " + e.getErrorMessage());
209208
}
210209
```
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

Comments
 (0)