Skip to content

Commit f3914d8

Browse files
author
Javen
committed
Prepare for new version - v3.1.0
1 parent e1b801c commit f3914d8

File tree

2 files changed

+35
-30
lines changed

2 files changed

+35
-30
lines changed

README.md

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,25 @@ maven package
9494
> 以下片断来自项目代码里的文件:cn.jpush.api.examples.PushExample
9595
9696
```
97-
JPushClient jpushClient = new JPushClient(masterSecret, appKey);
97+
JPushClient jpushClient = new JPushClient(masterSecret, appKey, 3);
98+
99+
// For push, all you need do is to build PushPayload object.
98100
PushPayload payload = buildPushObject_all_all_alert();
99-
LOG.info("Paylaod JSON - " + payload.toString());
100-
101-
PushResult result = jpushClient.sendPush(payload);
102-
if (result.isResultOK()) {
103-
LOG.debug(result.toString());
104-
} else {
105-
if (result.getErrorCode() > 0) {
106-
LOG.warn(result.getOriginalContent());
107-
} else {
108-
LOG.debug("Maybe connect error. Retry laster. ");
109-
}
101+
102+
try {
103+
PushResult result = jpushClient.sendPush(payload);
104+
LOG.info("Got result - " + result);
105+
106+
} catch (APIConnectionException e) {
107+
// Connection error, should retry later
108+
LOG.error("Connection error, should retry later", e);
109+
110+
} catch (APIRequestException e) {
111+
// Should review the error, and fix the request
112+
LOG.error("Should review the error, and fix the request", e);
113+
LOG.info("HTTP Status: " + e.getStatus());
114+
LOG.info("Error Code: " + e.getErrorCode());
115+
LOG.info("Error Message: " + e.getErrorMessage());
110116
}
111117
112118
```
@@ -193,21 +199,20 @@ maven package
193199
> 以下片断来自项目代码里的文件:cn.jpush.api.examples.ReportsExample
194200
195201
```
196-
JPushClient jpushClient = new JPushClient(masterSecret, appKey);
197-
ReceivedsResult receivedsResult = jpushClient.getReportReceiveds("1708010723,1774452771");
198-
LOG.debug("responseContent - " + receivedsResult.responseResult.responseContent);
199-
if (receivedsResult.isResultOK()) {
200-
LOG.info("Receiveds - " + receivedsResult);
201-
} else {
202-
if (receivedsResult.getErrorCode() > 0) {
203-
// 业务异常
204-
LOG.warn("Service error - ErrorCode: "
205-
+ receivedsResult.getErrorCode() + ", ErrorMessage: "
206-
+ receivedsResult.getErrorMessage());
207-
} else {
208-
// 未到达 JPush
209-
LOG.error("Other excepitons - "
210-
+ receivedsResult.responseResult.exceptionString);
211-
}
212-
}
202+
JPushClient jpushClient = new JPushClient(masterSecret, appKey);
203+
try {
204+
ReceivedsResult result = jpushClient.getReportReceiveds("1942377665");
205+
LOG.debug("Got result - " + result);
206+
207+
} catch (APIConnectionException e) {
208+
// Connection error, should retry later
209+
LOG.error("Connection error, should retry later", e);
210+
211+
} catch (APIRequestException e) {
212+
// Should review the error, and fix the request
213+
LOG.error("Should review the error, and fix the request", e);
214+
LOG.info("HTTP Status: " + e.getStatus());
215+
LOG.info("Error Code: " + e.getErrorCode());
216+
LOG.info("Error Message: " + e.getErrorMessage());
217+
}
213218
```

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>cn.jpush.api</groupId>
55
<artifactId>jpush-client</artifactId>
6-
<version>3.0.2-SNAPSHOT</version>
6+
<version>3.1.0-SNAPSHOT</version>
77
<packaging>jar</packaging>
88
<url>https://github.com/jpush/jpush-api-java-client</url>
99
<name>JPush API Java Client</name>

0 commit comments

Comments
 (0)