Skip to content

Commit 81a93ba

Browse files
committed
Merge pull request #41 from jpush/dev
merge version 3.2.8
2 parents 91e7107 + dcd48a8 commit 81a93ba

File tree

14 files changed

+664
-69
lines changed

14 files changed

+664
-69
lines changed

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>cn.jpush.api</groupId>
2828
<artifactId>jpush-client</artifactId>
29-
<version>3.2.7</version>
29+
<version>3.2.8</version>
3030
</dependency>
3131
```
3232
### jar 包方式
@@ -200,6 +200,26 @@
200200
}
201201
```
202202

203+
* 构建推送对象:推送内容包含SMS信息
204+
205+
```Java
206+
public static void testSendWithSMS() {
207+
JPushClient jpushClient = new JPushClient(masterSecret, appKey);
208+
try {
209+
SMS sms = SMS.content("Test SMS", 10);
210+
PushResult result = jpushClient.sendAndroidMessageWithAlias("Test SMS", "test sms", sms, "alias1");
211+
LOG.info("Got result - " + result);
212+
} catch (APIConnectionException e) {
213+
LOG.error("Connection error. Should retry later. ", e);
214+
} catch (APIRequestException e) {
215+
LOG.error("Error response from JPush server. Should review and fix it. ", e);
216+
LOG.info("HTTP Status: " + e.getStatus());
217+
LOG.info("Error Code: " + e.getErrorCode());
218+
LOG.info("Error Message: " + e.getErrorMessage());
219+
}
220+
}
221+
```
222+
203223
### 统计获取样例
204224

205225
> 以下片断来自项目代码里的文件:example / cn.jpush.api.examples.ReportsExample
@@ -227,6 +247,7 @@
227247

228248
> 以下片断来自项目代码里的文件:example / cn.jpush.api.examples.DeviceExample
229249
250+
* 获取Tag Alias
230251
```Java
231252
try {
232253
TagAliasResult result = jpushClient.getDeviceTagAlias(REGISTRATION_ID1);
@@ -243,6 +264,22 @@
243264
}
244265
```
245266

267+
* 绑定手机号
268+
269+
```Java
270+
try {
271+
DefaultResult result = jpushClient.bindMobile(REGISTRATION_ID1, "13000000000");
272+
LOG.info("Got result " + result);
273+
} catch (APIConnectionException e) {
274+
LOG.error("Connection error. Should retry later. ", e);
275+
} catch (APIRequestException e) {
276+
LOG.error("Error response from JPush server. Should review and fix it. ", e);
277+
LOG.info("HTTP Status: " + e.getStatus());
278+
LOG.info("Error Code: " + e.getErrorCode());
279+
LOG.info("Error Message: " + e.getErrorMessage());
280+
}
281+
```
282+
246283
### Schedule 样例
247284

248285
> 以下片断来自项目代码里的文件:example / cn.jpush.api.examples.ScheduleExample

example/main/java/cn/jpush/api/examples/DevcieExample.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cn.jpush.api.examples;
22

3+
import cn.jpush.api.common.resp.DefaultResult;
34
import cn.jpush.api.device.OnlineStatus;
45
import org.slf4j.Logger;
56
import org.slf4j.LoggerFactory;
@@ -62,6 +63,20 @@ public static void testGetUserOnlineStatus() {
6263
LOG.info("Error Message: " + e.getErrorMessage());
6364
}
6465
}
66+
67+
public static void testBindMobile() {
68+
try {
69+
DefaultResult result = jpushClient.bindMobile(REGISTRATION_ID1, "13000000000");
70+
LOG.info("Got result " + result);
71+
} catch (APIConnectionException e) {
72+
LOG.error("Connection error. Should retry later. ", e);
73+
} catch (APIRequestException e) {
74+
LOG.error("Error response from JPush server. Should review and fix it. ", e);
75+
LOG.info("HTTP Status: " + e.getStatus());
76+
LOG.info("Error Code: " + e.getErrorCode());
77+
LOG.info("Error Message: " + e.getErrorMessage());
78+
}
79+
}
6580

6681
}
6782

example/main/java/cn/jpush/api/examples/PushExample.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cn.jpush.api.examples;
22

33
import cn.jpush.api.common.ClientConfig;
4+
import cn.jpush.api.push.model.*;
45
import cn.jpush.api.push.model.notification.IosAlert;
56
import org.slf4j.Logger;
67
import org.slf4j.LoggerFactory;
@@ -9,10 +10,6 @@
910
import cn.jpush.api.common.resp.APIConnectionException;
1011
import cn.jpush.api.common.resp.APIRequestException;
1112
import cn.jpush.api.push.PushResult;
12-
import cn.jpush.api.push.model.Message;
13-
import cn.jpush.api.push.model.Options;
14-
import cn.jpush.api.push.model.Platform;
15-
import cn.jpush.api.push.model.PushPayload;
1613
import cn.jpush.api.push.model.audience.Audience;
1714
import cn.jpush.api.push.model.audience.AudienceTarget;
1815
import cn.jpush.api.push.model.notification.AndroidNotification;
@@ -178,5 +175,21 @@ public static void testSendIosAlert() {
178175
}
179176
}
180177

178+
public static void testSendWithSMS() {
179+
JPushClient jpushClient = new JPushClient(masterSecret, appKey);
180+
try {
181+
SMS sms = SMS.content("Test SMS", 10);
182+
PushResult result = jpushClient.sendAndroidMessageWithAlias("Test SMS", "test sms", sms, "alias1");
183+
LOG.info("Got result - " + result);
184+
} catch (APIConnectionException e) {
185+
LOG.error("Connection error. Should retry later. ", e);
186+
} catch (APIRequestException e) {
187+
LOG.error("Error response from JPush server. Should review and fix it. ", e);
188+
LOG.info("HTTP Status: " + e.getStatus());
189+
LOG.info("Error Code: " + e.getErrorCode());
190+
LOG.info("Error Message: " + e.getErrorMessage());
191+
}
192+
}
193+
181194
}
182195

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.2.8-SNAPSHOT</version>
6+
<version>3.2.8</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)