Skip to content

Commit 49e853f

Browse files
author
Javen
committed
Upgrade readme doc.
Use gh-pages to present apidocs from github site plugin.
1 parent dca799d commit 49e853f

File tree

3 files changed

+98
-16
lines changed

3 files changed

+98
-16
lines changed

README.md

Lines changed: 90 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,94 @@
1-
JPush API client library for Java
2-
==================================
1+
# JPush API client library for Java
32

4-
API 协议文档:
5-
http://docs.jpush.cn/pages/viewpage.action?pageId=2621796
3+
## 概述
4+
这是 JPush REST API 的 Java 版本封装开发包,是由极光推送官方提供的,一般支持最新的 API 功能。
5+
对应的 REST API 文档:<http://docs.jpush.cn/display/dev/REST+API>
6+
7+
## 安装
8+
### 直接使用 jar
9+
10+
```
11+
<dependency>
12+
<groupId>cn.jpush.api</groupId>
13+
<artifactId>jpush-client</artifactId>
14+
<version>2.3.0</version>
15+
</dependency>
16+
```
17+
18+
### 依赖包
19+
* gson
20+
* slf4j
21+
22+
> 其中 slf4j 可以与 logback, log4j, commons-logging 等日志框架一起工作,可根据你的需要配置使用。
23+
24+
### 构建本项目
25+
建议直接使用 maven。
26+
27+
## 使用样例
28+
下边是简单直接的使用样例。
29+
详细地了解请参考:[API Docs](http://jpush.github.io/jpush-api-java-client/apidocs/)
30+
31+
### 推送样例
32+
33+
```
34+
JPushClient jpushClient = new JPushClient(masterSecret, appKey, 0, DeviceEnum.Android, false);
35+
CustomMessageParams params = new CustomMessageParams();
36+
params.setReceiverType(ReceiverTypeEnum.TAG);
37+
params.setReceiverValue(tag);
38+
39+
MessageResult msgResult = jpushClient.sendCustomMessage(msgTitle, msgContent, params, null);
40+
LOG.debug("responseContent - " + msgResult.responseResult.responseContent);
41+
if (msgResult.isResultOK()) {
42+
LOG.info("msgResult - " + msgResult);
43+
LOG.info("messageId - " + msgResult.getMessageId());
44+
} else {
45+
if (msgResult.getErrorCode() > 0) {
46+
// 业务异常
47+
LOG.warn("Service error - ErrorCode: "
48+
+ msgResult.getErrorCode() + ", ErrorMessage: "
49+
+ msgResult.getErrorMessage());
50+
} else {
51+
// 未到达 JPush
52+
LOG.error("Other excepitons - "
53+
+ msgResult.responseResult.exceptionString);
54+
}
55+
}
56+
```
57+
58+
### 统计获取样例
59+
60+
```
61+
JPushClient jpushClient = new JPushClient(masterSecret, appKey);
62+
ReceivedsResult receivedsResult = jpushClient.getReportReceiveds("1708010723,1774452771");
63+
LOG.debug("responseContent - " + receivedsResult.responseResult.responseContent);
64+
if (receivedsResult.isResultOK()) {
65+
LOG.info("Receiveds - " + receivedsResult);
66+
} else {
67+
if (receivedsResult.getErrorCode() > 0) {
68+
// 业务异常
69+
LOG.warn("Service error - ErrorCode: "
70+
+ receivedsResult.getErrorCode() + ", ErrorMessage: "
71+
+ receivedsResult.getErrorMessage());
72+
} else {
73+
// 未到达 JPush
74+
LOG.error("Other excepitons - "
75+
+ receivedsResult.responseResult.exceptionString);
76+
}
77+
}
78+
```
79+
80+
81+
## 更新历史
82+
### r2.3.0 - 2014.01.08
83+
84+
这是一个完全重构版本,对整个项目的源代码以及公开的方法都进行了变更,但其基本功能未变更 。
85+
86+
#### 新功能
87+
* 增加支持 RegistrationID 推送。(如果 Android SDK r1.6.0 以上客户端支持;iOS 稍后发布的新版本SDK支持。)
88+
* 调用返回里可以取得频率控制相关信息
89+
90+
#### BUG修复
91+
* 未有
692

7-
其他语言的开发包:
8-
http://docs.jpush.cn/pages/viewpage.action?pageId=2228302
993

10-
JPush Change List:
11-
http://docs.jpush.cn/pages/viewpage.action?pageId=3309737
1294

pom.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<url>https://github.com/jpush/jpush-api-java-client</url>
2323
<properties>
2424
<github.global.server>github</github.global.server>
25+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2526
</properties>
2627

2728

@@ -122,15 +123,16 @@
122123
</plugins>
123124
</reporting>
124125
<scm>
126+
<url>https://github.com/jpush/jpush-api-java-client</url>
125127
<connection>scm:git:[email protected]:jpush/jpush-api-java-client.git</connection>
126128
<developerConnection>scm:git:[email protected]:jpush/jpush-api-java-client.git</developerConnection>
127-
<url>https://github.com/jpush/jpush-api-java-client</url>
128129
</scm>
129130
<developers>
130131
<developer>
131-
<id>xinxin</id>
132-
<name>xinxin</name>
133-
<email>[email protected]</email>
132+
<id>jpush</id>
133+
<name>JPush</name>
134+
<email>[email protected]</email>
135+
<url>https://github.com/jpush</url>
134136
</developer>
135137
</developers>
136138

src/cn/jpush/api/examples/JPushClientExample.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@ public class JPushClientExample {
2222
public static final String registrationID = "0900e8d85ef";
2323
public static final String tag = "tag_api";
2424

25-
private static JPushClient jpushClient = null;
26-
2725
public static void main(String[] args) {
28-
jpushClient = new JPushClient(masterSecret, appKey, 0, DeviceEnum.Android, false);
29-
3026
testSend();
3127
testGetReport();
3228
}
3329

3430
private static void testSend() {
31+
JPushClient jpushClient = new JPushClient(masterSecret, appKey, 0, DeviceEnum.Android, false);
3532
CustomMessageParams params = new CustomMessageParams();
3633
//params.setReceiverType(ReceiverTypeEnum.REGISTRATION_ID);
3734
//params.setReceiverValue(registrationID);
@@ -58,6 +55,7 @@ private static void testSend() {
5855
}
5956

6057
public static void testGetReport() {
58+
JPushClient jpushClient = new JPushClient(masterSecret, appKey);
6159
ReceivedsResult receivedsResult = jpushClient.getReportReceiveds("1708010723,1774452771");
6260
LOG.debug("responseContent - " + receivedsResult.responseResult.responseContent);
6361
if (receivedsResult.isResultOK()) {

0 commit comments

Comments
 (0)