Skip to content

Commit c2d0245

Browse files
committed
update version to 5.1.6.
1 parent 06b44f9 commit c2d0245

File tree

14 files changed

+196
-10
lines changed

14 files changed

+196
-10
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ replay_pid*
2626
*.iml
2727

2828
.idea
29-
target/
29+
**/target/

README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
## 1. 集成
1616
引入sdk包
1717
```xml
18-
<!--以5.1.5版本为例-->
18+
<!--以5.1.6版本为例-->
1919
<dependencies>
2020
<!-- jiguang-sdk -->
2121
<dependency>
2222
<groupId>io.github.jpush</groupId>
2323
<artifactId>jiguang-sdk</artifactId>
24-
<version>5.1.5</version>
24+
<version>5.1.6</version>
2525
</dependency>
2626
</dependencies>
2727
```
@@ -87,3 +87,8 @@
8787
* [ReportApi](https://github.com/jpush/jiguang-sdk-java/blob/main/example-for-spring/src/test/java/cn/jiguang/app/api/ReportApiTest.java)
8888
* [AdminApi](https://github.com/jpush/jiguang-sdk-java/blob/main/example-for-spring/src/test/java/cn/jiguang/app/api/AdminApiTest.java)
8989
* [GroupPushApi](https://github.com/jpush/jiguang-sdk-java/blob/main/example-for-spring/src/test/java/cn/jiguang/app/api/GroupPushApiTest.java)
90+
## 3. 推送失败
91+
推送失败会抛出异常,可对下面的类异常捕获后进行业务处理
92+
```java
93+
cn.jiguang.sdk.exception.ApiErrorException
94+
```

example-for-spring/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<groupId>io.github.jpush</groupId>
1515
<artifactId>example-for-spring</artifactId>
16-
<version>5.1.5</version>
16+
<version>5.1.6</version>
1717

1818
<properties>
1919
<maven.compiler.source>8</maven.compiler.source>
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>io.github.jpush</groupId>
2828
<artifactId>jiguang-sdk</artifactId>
29-
<version>5.1.5</version>
29+
<version>5.1.6</version>
3030
</dependency>
3131
<!-- lombok -->
3232
<dependency>

example-for-spring/src/main/java/cn/jiguang/app/config/JiguangApiConfig.java

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public PushApi pushApi(@Qualifier("okHttpClient") OkHttpClient okHttpClient) {
5252
.setClient(okHttpClient) // 如果不配置client,则使用默认的okHttpClient
5353
.setAppKey(appKey)
5454
.setMasterSecret(masterSecret)
55+
.setLoggerLevel(Logger.Level.FULL)
5556
.build();
5657
}
5758

example-for-spring/src/main/resources/application.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ logging:
1212
jiguang:
1313
api:
1414
# 此为演示数据,请替换成真实数据
15-
app-key: a266cd5c8544ba09b23733e1
16-
master-secret: bcf3b3327000abce4764f862
15+
app-key: b266cd5c8544ba09b23733e3
16+
master-secret: 15747d3881d308fe5107b7da
1717
dev-key: c2dc75e97486529205528b23
1818
dev-secret: d219e2f001df2fe4f08b6754
1919
group-key: 2ed1465b94aab3f03f6778e0

example-for-spring/src/test/java/cn/jiguang/app/api/PushApiTest.java

+54
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
import cn.jiguang.sdk.bean.push.PushSendParam;
1010
import cn.jiguang.sdk.bean.push.PushSendResult;
1111
import cn.jiguang.sdk.bean.push.audience.Audience;
12+
import cn.jiguang.sdk.bean.push.batch.BatchPushParam;
13+
import cn.jiguang.sdk.bean.push.batch.BatchPushSendParam;
14+
import cn.jiguang.sdk.bean.push.batch.BatchPushSendResult;
1215
import cn.jiguang.sdk.bean.push.message.notification.NotificationMessage;
1316
import cn.jiguang.sdk.bean.push.options.Options;
1417
import cn.jiguang.sdk.bean.push.other.CidGetResult;
@@ -254,4 +257,55 @@ public void updateImageFile() {
254257
log.info("result:{}", result);
255258
}
256259

260+
@Test
261+
public void batchSendByRegistrationId() {
262+
NotificationMessage.Android android = new NotificationMessage.Android();
263+
android.setAlert("this is android alert");
264+
android.setTitle("this is android title");
265+
NotificationMessage notificationMessage = new NotificationMessage();
266+
notificationMessage.setAndroid(android);
267+
268+
BatchPushParam pushParam = new BatchPushParam();
269+
pushParam.setTarget("170976fa8b808c38fe7");
270+
pushParam.setNotification(notificationMessage);
271+
pushParam.setPlatform(Arrays.asList(Platform.android, Platform.ios));
272+
273+
Map<String, BatchPushParam> pushSendParam = new HashMap<>();
274+
pushSendParam.put("b266cd5c8544ba09b23733e3-c7f656ad-12a3-4807-a614-9924dc11d79e", pushParam);
275+
pushSendParam.put("b266cd5c8544ba09b23733e3-0cbee7fc-e7ba-4b87-952e-14c5be18e671", pushParam);
276+
pushSendParam.put("b266cd5c8544ba09b23733e3-870bec54-f0e7-4ae0-a1f9-f13b4ddd1629", pushParam);
277+
278+
BatchPushSendParam param = new BatchPushSendParam();
279+
param.setSendParam(pushSendParam);
280+
281+
BatchPushSendResult result = pushApi.batchSendByRegistrationId(param);
282+
log.info("result:{}", result);
283+
}
284+
285+
@Test
286+
public void batchSendByAlias() {
287+
NotificationMessage.Android android = new NotificationMessage.Android();
288+
android.setAlert("this is android alert");
289+
android.setTitle("this is android title");
290+
NotificationMessage notificationMessage = new NotificationMessage();
291+
notificationMessage.setAndroid(android);
292+
293+
BatchPushParam pushParam = new BatchPushParam();
294+
pushParam.setTarget("alias1");
295+
pushParam.setNotification(notificationMessage);
296+
pushParam.setPlatform(Arrays.asList(Platform.android, Platform.ios));
297+
298+
Map<String, BatchPushParam> pushSendParam = new HashMap<>();
299+
pushSendParam.put("b266cd5c8544ba09b23733e3-6386dd3c-87dd-42c8-b721-a184ea323371", pushParam);
300+
pushSendParam.put("b266cd5c8544ba09b23733e3-999c861b-426c-475d-97c8-0cb884e67dfd", pushParam);
301+
pushSendParam.put("b266cd5c8544ba09b23733e3-d6296fc1-8e7b-4fdd-81ee-019de077bd97", pushParam);
302+
303+
BatchPushSendParam param = new BatchPushSendParam();
304+
param.setSendParam(pushSendParam);
305+
306+
BatchPushSendResult result = pushApi.batchSendByAlias(param);
307+
log.info("result:{}", result);
308+
}
309+
310+
257311
}

jiguang-sdk/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<parent>
88
<groupId>io.github.jpush</groupId>
99
<artifactId>jiguang-sdk-java</artifactId>
10-
<version>5.1.5</version>
10+
<version>5.1.6</version>
1111
<relativePath>../pom.xml</relativePath>
1212
</parent>
1313

1414
<groupId>io.github.jpush</groupId>
1515
<artifactId>jiguang-sdk</artifactId>
16-
<version>5.1.5</version>
16+
<version>5.1.6</version>
1717
<packaging>jar</packaging>
1818

1919
<properties>

jiguang-sdk/src/main/java/cn/jiguang/sdk/api/PushApi.java

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import cn.jiguang.sdk.bean.push.PushSendResult;
1010
import cn.jiguang.sdk.bean.push.SchedulePushSendParam;
1111
import cn.jiguang.sdk.bean.push.SchedulePushSendResult;
12+
import cn.jiguang.sdk.bean.push.batch.BatchPushSendParam;
13+
import cn.jiguang.sdk.bean.push.batch.BatchPushSendResult;
1214
import cn.jiguang.sdk.bean.push.other.CidGetResult;
1315
import cn.jiguang.sdk.bean.push.other.QuotaGetResult;
1416
import cn.jiguang.sdk.client.PushClient;
@@ -99,6 +101,14 @@ public ImageFileUpdateResult updateImageFile(@NonNull String mediaId, @NonNull I
99101
return pushClient.updateImageFile(mediaId, param);
100102
}
101103

104+
public BatchPushSendResult batchSendByRegistrationId(BatchPushSendParam param) {
105+
return pushClient.batchSendByRegistrationId(param);
106+
}
107+
108+
public BatchPushSendResult batchSendByAlias(BatchPushSendParam param) {
109+
return pushClient.batchSendByAlias(param);
110+
}
111+
102112
// ********************* 如果遇到此api没有及时补充字段的情况,可以自行构建json,调用下面的接口 *********************
103113

104114
public PushSendResult send(Object param) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package cn.jiguang.sdk.bean.push.batch;
2+
3+
import cn.jiguang.sdk.bean.push.callback.Callback;
4+
import cn.jiguang.sdk.bean.push.message.custom.CustomMessage;
5+
import cn.jiguang.sdk.bean.push.message.notification.NotificationMessage;
6+
import cn.jiguang.sdk.bean.push.message.sms.SmsMessage;
7+
import cn.jiguang.sdk.bean.push.options.Options;
8+
import cn.jiguang.sdk.enums.platform.Platform;
9+
import com.fasterxml.jackson.annotation.JsonInclude;
10+
import com.fasterxml.jackson.annotation.JsonProperty;
11+
import lombok.Data;
12+
13+
@Data
14+
public class BatchPushParam {
15+
16+
/**
17+
* 此处填写的是 regId 值或者 alias 值
18+
*/
19+
@JsonProperty("target")
20+
private String target;
21+
22+
/**
23+
* 两种格式
24+
* 字符串:"all"
25+
* {@link Platform}数组:["android","ios","hmos","quickapp"]
26+
*/
27+
@JsonProperty("platform")
28+
private Object platform;
29+
30+
@JsonProperty("options")
31+
@JsonInclude(JsonInclude.Include.NON_NULL)
32+
private Options options;
33+
34+
@JsonProperty("notification")
35+
@JsonInclude(JsonInclude.Include.NON_NULL)
36+
private NotificationMessage notification;
37+
38+
@JsonProperty("message")
39+
@JsonInclude(JsonInclude.Include.NON_NULL)
40+
private CustomMessage custom;
41+
42+
@JsonProperty("sms_message")
43+
@JsonInclude(JsonInclude.Include.NON_NULL)
44+
private SmsMessage smsMessage;
45+
46+
@JsonProperty("callback")
47+
@JsonInclude(JsonInclude.Include.NON_NULL)
48+
private Callback callback;
49+
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package cn.jiguang.sdk.bean.push.batch;
2+
3+
import cn.jiguang.sdk.exception.ApiErrorException;
4+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import com.fasterxml.jackson.annotation.JsonInclude;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
import lombok.Data;
8+
9+
@Data
10+
@JsonIgnoreProperties(ignoreUnknown = true)
11+
public class BatchPushResult {
12+
13+
@JsonProperty("msg_id")
14+
@JsonInclude(JsonInclude.Include.NON_NULL)
15+
private String messageId;
16+
17+
@JsonProperty("error")
18+
@JsonInclude(JsonInclude.Include.NON_NULL)
19+
private ApiErrorException.ApiError.Error error;
20+
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package cn.jiguang.sdk.bean.push.batch;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Data;
5+
6+
import java.util.Map;
7+
8+
@Data
9+
public class BatchPushSendParam {
10+
11+
@JsonProperty("pushlist")
12+
private Map<String, BatchPushParam> sendParam;
13+
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package cn.jiguang.sdk.bean.push.batch;
2+
3+
import com.fasterxml.jackson.annotation.JsonAnySetter;
4+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import lombok.Data;
6+
7+
import java.util.HashMap;
8+
import java.util.Map;
9+
10+
@Data
11+
@JsonIgnoreProperties(ignoreUnknown = true)
12+
public class BatchPushSendResult {
13+
14+
private Map<String, BatchPushResult> sendResult = new HashMap<>();
15+
16+
@JsonAnySetter
17+
public void addResult(String key, BatchPushResult value) {
18+
sendResult.put(key, value);
19+
}
20+
21+
}

jiguang-sdk/src/main/java/cn/jiguang/sdk/client/PushClient.java

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import cn.jiguang.sdk.bean.push.PushSendResult;
1010
import cn.jiguang.sdk.bean.push.SchedulePushSendParam;
1111
import cn.jiguang.sdk.bean.push.SchedulePushSendResult;
12+
import cn.jiguang.sdk.bean.push.batch.BatchPushSendParam;
13+
import cn.jiguang.sdk.bean.push.batch.BatchPushSendResult;
1214
import cn.jiguang.sdk.bean.push.other.CidGetResult;
1315
import cn.jiguang.sdk.bean.push.other.QuotaGetResult;
1416
import feign.Headers;
@@ -88,6 +90,14 @@ public interface PushClient {
8890
@Headers("Content-Type: multipart/form-data")
8991
ImageFileUpdateResult updateImageFile(@Param("media_id") String mediaId, ImageFileUpdateParam param);
9092

93+
@RequestLine("POST /v3/push/batch/regid/single")
94+
@Headers("Content-Type: application/json; charset=utf-8")
95+
BatchPushSendResult batchSendByRegistrationId(BatchPushSendParam param);
96+
97+
@RequestLine("POST /v3/push/batch/alias/single")
98+
@Headers("Content-Type: application/json; charset=utf-8")
99+
BatchPushSendResult batchSendByAlias(BatchPushSendParam param);
100+
91101
// ********************* 如果遇到此api没有及时补充字段的情况,可以自行构建json,调用下面的接口 *********************
92102

93103
@RequestLine("POST /v3/push")

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.jpush</groupId>
88
<artifactId>jiguang-sdk-java</artifactId>
9-
<version>5.1.5</version>
9+
<version>5.1.6</version>
1010
<packaging>pom</packaging>
1111

1212
<name>Jiguang SDK For Rest Api</name>

0 commit comments

Comments
 (0)