Skip to content

Commit

Permalink
update version to 5.1.6.
Browse files Browse the repository at this point in the history
  • Loading branch information
wicked-tc130 committed Aug 28, 2024
1 parent 06b44f9 commit c2d0245
Show file tree
Hide file tree
Showing 14 changed files with 196 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ replay_pid*
*.iml

.idea
target/
**/target/
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
## 1. 集成
引入sdk包
```xml
<!--以5.1.5版本为例-->
<!--以5.1.6版本为例-->
<dependencies>
<!-- jiguang-sdk -->
<dependency>
<groupId>io.github.jpush</groupId>
<artifactId>jiguang-sdk</artifactId>
<version>5.1.5</version>
<version>5.1.6</version>
</dependency>
</dependencies>
```
Expand Down Expand Up @@ -87,3 +87,8 @@
* [ReportApi](https://github.com/jpush/jiguang-sdk-java/blob/main/example-for-spring/src/test/java/cn/jiguang/app/api/ReportApiTest.java)
* [AdminApi](https://github.com/jpush/jiguang-sdk-java/blob/main/example-for-spring/src/test/java/cn/jiguang/app/api/AdminApiTest.java)
* [GroupPushApi](https://github.com/jpush/jiguang-sdk-java/blob/main/example-for-spring/src/test/java/cn/jiguang/app/api/GroupPushApiTest.java)
## 3. 推送失败
推送失败会抛出异常,可对下面的类异常捕获后进行业务处理
```java
cn.jiguang.sdk.exception.ApiErrorException
```
4 changes: 2 additions & 2 deletions example-for-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>io.github.jpush</groupId>
<artifactId>example-for-spring</artifactId>
<version>5.1.5</version>
<version>5.1.6</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand All @@ -26,7 +26,7 @@
<dependency>
<groupId>io.github.jpush</groupId>
<artifactId>jiguang-sdk</artifactId>
<version>5.1.5</version>
<version>5.1.6</version>
</dependency>
<!-- lombok -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public PushApi pushApi(@Qualifier("okHttpClient") OkHttpClient okHttpClient) {
.setClient(okHttpClient) // 如果不配置client,则使用默认的okHttpClient
.setAppKey(appKey)
.setMasterSecret(masterSecret)
.setLoggerLevel(Logger.Level.FULL)
.build();
}

Expand Down
4 changes: 2 additions & 2 deletions example-for-spring/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ logging:
jiguang:
api:
# 此为演示数据,请替换成真实数据
app-key: a266cd5c8544ba09b23733e1
master-secret: bcf3b3327000abce4764f862
app-key: b266cd5c8544ba09b23733e3
master-secret: 15747d3881d308fe5107b7da
dev-key: c2dc75e97486529205528b23
dev-secret: d219e2f001df2fe4f08b6754
group-key: 2ed1465b94aab3f03f6778e0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import cn.jiguang.sdk.bean.push.PushSendParam;
import cn.jiguang.sdk.bean.push.PushSendResult;
import cn.jiguang.sdk.bean.push.audience.Audience;
import cn.jiguang.sdk.bean.push.batch.BatchPushParam;
import cn.jiguang.sdk.bean.push.batch.BatchPushSendParam;
import cn.jiguang.sdk.bean.push.batch.BatchPushSendResult;
import cn.jiguang.sdk.bean.push.message.notification.NotificationMessage;
import cn.jiguang.sdk.bean.push.options.Options;
import cn.jiguang.sdk.bean.push.other.CidGetResult;
Expand Down Expand Up @@ -254,4 +257,55 @@ public void updateImageFile() {
log.info("result:{}", result);
}

@Test
public void batchSendByRegistrationId() {
NotificationMessage.Android android = new NotificationMessage.Android();
android.setAlert("this is android alert");
android.setTitle("this is android title");
NotificationMessage notificationMessage = new NotificationMessage();
notificationMessage.setAndroid(android);

BatchPushParam pushParam = new BatchPushParam();
pushParam.setTarget("170976fa8b808c38fe7");
pushParam.setNotification(notificationMessage);
pushParam.setPlatform(Arrays.asList(Platform.android, Platform.ios));

Map<String, BatchPushParam> pushSendParam = new HashMap<>();
pushSendParam.put("b266cd5c8544ba09b23733e3-c7f656ad-12a3-4807-a614-9924dc11d79e", pushParam);
pushSendParam.put("b266cd5c8544ba09b23733e3-0cbee7fc-e7ba-4b87-952e-14c5be18e671", pushParam);
pushSendParam.put("b266cd5c8544ba09b23733e3-870bec54-f0e7-4ae0-a1f9-f13b4ddd1629", pushParam);

BatchPushSendParam param = new BatchPushSendParam();
param.setSendParam(pushSendParam);

BatchPushSendResult result = pushApi.batchSendByRegistrationId(param);
log.info("result:{}", result);
}

@Test
public void batchSendByAlias() {
NotificationMessage.Android android = new NotificationMessage.Android();
android.setAlert("this is android alert");
android.setTitle("this is android title");
NotificationMessage notificationMessage = new NotificationMessage();
notificationMessage.setAndroid(android);

BatchPushParam pushParam = new BatchPushParam();
pushParam.setTarget("alias1");
pushParam.setNotification(notificationMessage);
pushParam.setPlatform(Arrays.asList(Platform.android, Platform.ios));

Map<String, BatchPushParam> pushSendParam = new HashMap<>();
pushSendParam.put("b266cd5c8544ba09b23733e3-6386dd3c-87dd-42c8-b721-a184ea323371", pushParam);
pushSendParam.put("b266cd5c8544ba09b23733e3-999c861b-426c-475d-97c8-0cb884e67dfd", pushParam);
pushSendParam.put("b266cd5c8544ba09b23733e3-d6296fc1-8e7b-4fdd-81ee-019de077bd97", pushParam);

BatchPushSendParam param = new BatchPushSendParam();
param.setSendParam(pushSendParam);

BatchPushSendResult result = pushApi.batchSendByAlias(param);
log.info("result:{}", result);
}


}
4 changes: 2 additions & 2 deletions jiguang-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<parent>
<groupId>io.github.jpush</groupId>
<artifactId>jiguang-sdk-java</artifactId>
<version>5.1.5</version>
<version>5.1.6</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>io.github.jpush</groupId>
<artifactId>jiguang-sdk</artifactId>
<version>5.1.5</version>
<version>5.1.6</version>
<packaging>jar</packaging>

<properties>
Expand Down
10 changes: 10 additions & 0 deletions jiguang-sdk/src/main/java/cn/jiguang/sdk/api/PushApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import cn.jiguang.sdk.bean.push.PushSendResult;
import cn.jiguang.sdk.bean.push.SchedulePushSendParam;
import cn.jiguang.sdk.bean.push.SchedulePushSendResult;
import cn.jiguang.sdk.bean.push.batch.BatchPushSendParam;
import cn.jiguang.sdk.bean.push.batch.BatchPushSendResult;
import cn.jiguang.sdk.bean.push.other.CidGetResult;
import cn.jiguang.sdk.bean.push.other.QuotaGetResult;
import cn.jiguang.sdk.client.PushClient;
Expand Down Expand Up @@ -99,6 +101,14 @@ public ImageFileUpdateResult updateImageFile(@NonNull String mediaId, @NonNull I
return pushClient.updateImageFile(mediaId, param);
}

public BatchPushSendResult batchSendByRegistrationId(BatchPushSendParam param) {
return pushClient.batchSendByRegistrationId(param);
}

public BatchPushSendResult batchSendByAlias(BatchPushSendParam param) {
return pushClient.batchSendByAlias(param);
}

// ********************* 如果遇到此api没有及时补充字段的情况,可以自行构建json,调用下面的接口 *********************

public PushSendResult send(Object param) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package cn.jiguang.sdk.bean.push.batch;

import cn.jiguang.sdk.bean.push.callback.Callback;
import cn.jiguang.sdk.bean.push.message.custom.CustomMessage;
import cn.jiguang.sdk.bean.push.message.notification.NotificationMessage;
import cn.jiguang.sdk.bean.push.message.sms.SmsMessage;
import cn.jiguang.sdk.bean.push.options.Options;
import cn.jiguang.sdk.enums.platform.Platform;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

@Data
public class BatchPushParam {

/**
* 此处填写的是 regId 值或者 alias 值
*/
@JsonProperty("target")
private String target;

/**
* 两种格式
* 字符串:"all"
* {@link Platform}数组:["android","ios","hmos","quickapp"]
*/
@JsonProperty("platform")
private Object platform;

@JsonProperty("options")
@JsonInclude(JsonInclude.Include.NON_NULL)
private Options options;

@JsonProperty("notification")
@JsonInclude(JsonInclude.Include.NON_NULL)
private NotificationMessage notification;

@JsonProperty("message")
@JsonInclude(JsonInclude.Include.NON_NULL)
private CustomMessage custom;

@JsonProperty("sms_message")
@JsonInclude(JsonInclude.Include.NON_NULL)
private SmsMessage smsMessage;

@JsonProperty("callback")
@JsonInclude(JsonInclude.Include.NON_NULL)
private Callback callback;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cn.jiguang.sdk.bean.push.batch;

import cn.jiguang.sdk.exception.ApiErrorException;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class BatchPushResult {

@JsonProperty("msg_id")
@JsonInclude(JsonInclude.Include.NON_NULL)
private String messageId;

@JsonProperty("error")
@JsonInclude(JsonInclude.Include.NON_NULL)
private ApiErrorException.ApiError.Error error;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package cn.jiguang.sdk.bean.push.batch;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.Map;

@Data
public class BatchPushSendParam {

@JsonProperty("pushlist")
private Map<String, BatchPushParam> sendParam;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cn.jiguang.sdk.bean.push.batch;

import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class BatchPushSendResult {

private Map<String, BatchPushResult> sendResult = new HashMap<>();

@JsonAnySetter
public void addResult(String key, BatchPushResult value) {
sendResult.put(key, value);
}

}
10 changes: 10 additions & 0 deletions jiguang-sdk/src/main/java/cn/jiguang/sdk/client/PushClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import cn.jiguang.sdk.bean.push.PushSendResult;
import cn.jiguang.sdk.bean.push.SchedulePushSendParam;
import cn.jiguang.sdk.bean.push.SchedulePushSendResult;
import cn.jiguang.sdk.bean.push.batch.BatchPushSendParam;
import cn.jiguang.sdk.bean.push.batch.BatchPushSendResult;
import cn.jiguang.sdk.bean.push.other.CidGetResult;
import cn.jiguang.sdk.bean.push.other.QuotaGetResult;
import feign.Headers;
Expand Down Expand Up @@ -88,6 +90,14 @@ public interface PushClient {
@Headers("Content-Type: multipart/form-data")
ImageFileUpdateResult updateImageFile(@Param("media_id") String mediaId, ImageFileUpdateParam param);

@RequestLine("POST /v3/push/batch/regid/single")
@Headers("Content-Type: application/json; charset=utf-8")
BatchPushSendResult batchSendByRegistrationId(BatchPushSendParam param);

@RequestLine("POST /v3/push/batch/alias/single")
@Headers("Content-Type: application/json; charset=utf-8")
BatchPushSendResult batchSendByAlias(BatchPushSendParam param);

// ********************* 如果遇到此api没有及时补充字段的情况,可以自行构建json,调用下面的接口 *********************

@RequestLine("POST /v3/push")
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.jpush</groupId>
<artifactId>jiguang-sdk-java</artifactId>
<version>5.1.5</version>
<version>5.1.6</version>
<packaging>pom</packaging>

<name>Jiguang SDK For Rest Api</name>
Expand Down

0 comments on commit c2d0245

Please sign in to comment.