Skip to content

Commit

Permalink
Merge pull request #41 from jpush/dev
Browse files Browse the repository at this point in the history
merge version 3.2.8
  • Loading branch information
Liuchy1 committed Dec 14, 2015
2 parents 91e7107 + dcd48a8 commit 81a93ba
Show file tree
Hide file tree
Showing 14 changed files with 664 additions and 69 deletions.
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<dependency>
<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
<version>3.2.7</version>
<version>3.2.8</version>
</dependency>
```
### jar 包方式
Expand Down Expand Up @@ -200,6 +200,26 @@
}
```

* 构建推送对象:推送内容包含SMS信息

```Java
public static void testSendWithSMS() {
JPushClient jpushClient = new JPushClient(masterSecret, appKey);
try {
SMS sms = SMS.content("Test SMS", 10);
PushResult result = jpushClient.sendAndroidMessageWithAlias("Test SMS", "test sms", sms, "alias1");
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
}
```

### 统计获取样例

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

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

* 绑定手机号

```Java
try {
DefaultResult result = jpushClient.bindMobile(REGISTRATION_ID1, "13000000000");
LOG.info("Got result " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
```

### Schedule 样例

> 以下片断来自项目代码里的文件:example / cn.jpush.api.examples.ScheduleExample
Expand Down
15 changes: 15 additions & 0 deletions example/main/java/cn/jpush/api/examples/DevcieExample.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cn.jpush.api.examples;

import cn.jpush.api.common.resp.DefaultResult;
import cn.jpush.api.device.OnlineStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -62,6 +63,20 @@ public static void testGetUserOnlineStatus() {
LOG.info("Error Message: " + e.getErrorMessage());
}
}

public static void testBindMobile() {
try {
DefaultResult result = jpushClient.bindMobile(REGISTRATION_ID1, "13000000000");
LOG.info("Got result " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
}

}

Expand Down
21 changes: 17 additions & 4 deletions example/main/java/cn/jpush/api/examples/PushExample.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.jpush.api.examples;

import cn.jpush.api.common.ClientConfig;
import cn.jpush.api.push.model.*;
import cn.jpush.api.push.model.notification.IosAlert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -9,10 +10,6 @@
import cn.jpush.api.common.resp.APIConnectionException;
import cn.jpush.api.common.resp.APIRequestException;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.Message;
import cn.jpush.api.push.model.Options;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.audience.AudienceTarget;
import cn.jpush.api.push.model.notification.AndroidNotification;
Expand Down Expand Up @@ -178,5 +175,21 @@ public static void testSendIosAlert() {
}
}

public static void testSendWithSMS() {
JPushClient jpushClient = new JPushClient(masterSecret, appKey);
try {
SMS sms = SMS.content("Test SMS", 10);
PushResult result = jpushClient.sendAndroidMessageWithAlias("Test SMS", "test sms", sms, "alias1");
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
}

}

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId>
<version>3.2.8-SNAPSHOT</version>
<version>3.2.8</version>
<packaging>jar</packaging>
<url>https://github.com/jpush/jpush-api-java-client</url>
<name>JPush API Java Client</name>
Expand Down
Loading

0 comments on commit 81a93ba

Please sign in to comment.