Skip to content

Commit d3f5c49

Browse files
author
Javen
committed
Update readme for api v3
1 parent 7ebd4a0 commit d3f5c49

File tree

1 file changed

+16
-27
lines changed

1 file changed

+16
-27
lines changed

README.md

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
### 构建本项目
4747
建议直接使用 maven,执行命令:
4848
```
49-
maven package
49+
maven package
5050
```
5151

5252
## 使用样例
@@ -56,28 +56,21 @@ maven package
5656
### 推送样例
5757

5858
```
59-
JPushClient jpushClient = new JPushClient(masterSecret, appKey, 0, DeviceEnum.Android, false);
60-
CustomMessageParams params = new CustomMessageParams();
61-
params.setReceiverType(ReceiverTypeEnum.TAG);
62-
params.setReceiverValue(tag);
63-
64-
MessageResult msgResult = jpushClient.sendCustomMessage(msgTitle, msgContent, params, null);
65-
LOG.debug("responseContent - " + msgResult.responseResult.responseContent);
66-
if (msgResult.isResultOK()) {
67-
LOG.info("msgResult - " + msgResult);
68-
LOG.info("messageId - " + msgResult.getMessageId());
69-
} else {
70-
if (msgResult.getErrorCode() > 0) {
71-
// 业务异常
72-
LOG.warn("Service error - ErrorCode: "
73-
+ msgResult.getErrorCode() + ", ErrorMessage: "
74-
+ msgResult.getErrorMessage());
75-
} else {
76-
// 未到达 JPush
77-
LOG.error("Other excepitons - "
78-
+ msgResult.responseResult.exceptionString);
79-
}
80-
}
59+
JPushClient jpushClient = new JPushClient(masterSecret, appKey);
60+
PushPayload payload = PushPayload.alertAll("Hi, JPush!");
61+
LOG.info("Paylaod JSON - " + payload.toString());
62+
63+
PushResult result = jpushClient.sendPush(payload);
64+
if (result.isResultOK()) {
65+
LOG.debug(result.toString());
66+
} else {
67+
if (result.getErrorCode() > 0) {
68+
LOG.warn(result.getOriginalContent());
69+
} else {
70+
LOG.debug("Maybe connect error. Retry laster. ");
71+
}
72+
}
73+
8174
```
8275

8376
### 统计获取样例
@@ -106,7 +99,3 @@ if (receivedsResult.isResultOK()) {
10699
## 版本更新
107100

108101
[Release页面](https://github.com/jpush/jpush-api-java-client/releases) 有详细的版本发布记录与下载。
109-
110-
111-
112-

0 commit comments

Comments
 (0)