Skip to content

Commit 9b8a20a

Browse files
authored
Merge pull request #56 from ZJUCJH/main
[feature] 1.鸿蒙厂商通道通知消息支持自定义消息、消息覆盖和消息撤回;2.关闭CloseableHttpClient内默认的重试机制
2 parents 1a90a52 + 7aa67a6 commit 9b8a20a

File tree

8 files changed

+106
-15
lines changed

8 files changed

+106
-15
lines changed

CHANGES.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Release Notes
22

3+
## 1.0.6.0
4+
5+
### update
6+
7+
* 鸿蒙厂商通道通知消息支持自定义消息、消息覆盖和消息撤回
8+
* 关闭CloseableHttpClient内默认的重试机制
9+
310
## 1.0.5.0
411

512
### update
@@ -41,7 +48,8 @@
4148
* 重试支持切换域名
4249
* 支持设置接口维度的超时时间
4350
* 修改默认的连接超时时间,60s改为10s
44-
* 内部异常,会拼接到apiResult的msg上,eg. 原来接口超时返回`{"code":5000, "message":"http error::5000"}`,修改后返回`{"code":5000, "message":"http error:Read timed out::5000"}
51+
* 内部异常,会拼接到apiResult的msg上,eg. 原来接口超时返回`{"code":5000, "message":"http error::5000"}`,修改后返回`{"
52+
code":5000, "message":"http error:Read timed out::5000"}
4553

4654
## 1.0.0.17
4755

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<dependency>
2323
<groupId>com.getui.push</groupId>
2424
<artifactId>restful-sdk</artifactId>
25-
<version>1.0.5.0</version>
25+
<version>1.0.6.0</version>
2626
</dependency>
2727
```
2828

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>com.getui.push</groupId>
88
<artifactId>restful-sdk</artifactId>
99
<packaging>jar</packaging>
10-
<version>1.0.5.0</version>
10+
<version>1.0.6.0</version>
1111
<url>https://github.com/GetuiLaboratory/getui-pushapi-java-client-v2</url>
1212
<name>Getui Push API Java Client</name>
1313
<description>Getui's officially supported Java client library for accessing Getui APIs.</description>

src/main/java/com/getui/push/v2/sdk/common/http/GtHttpClient.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616
import org.apache.http.client.methods.*;
1717
import org.apache.http.entity.ContentType;
1818
import org.apache.http.entity.StringEntity;
19-
import org.apache.http.impl.client.BasicCredentialsProvider;
20-
import org.apache.http.impl.client.CloseableHttpClient;
21-
import org.apache.http.impl.client.HttpClientBuilder;
22-
import org.apache.http.impl.client.HttpClients;
19+
import org.apache.http.impl.client.*;
2320
import org.apache.http.util.EntityUtils;
2421
import org.slf4j.Logger;
2522
import org.slf4j.LoggerFactory;
@@ -58,6 +55,8 @@ public GtHttpClient(int connectTimeout,
5855
}
5956
this.maxHttpTryTime = maxHttpTryTime;
6057
final HttpClientBuilder builder = HttpClients.custom();
58+
// 关闭CloseableHttpClient内默认的重试机制
59+
builder.setRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
6160
if (proxyConfig != null && Utils.isNotEmpty(proxyConfig.getHost())) {
6261
if (Utils.isNotEmpty(proxyConfig.getUsername())) {
6362
CredentialsProvider credsProvider = new BasicCredentialsProvider();

src/main/java/com/getui/push/v2/sdk/core/Configs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public interface Configs {
1313

1414
String HEADER_DOMAIN_HASH_KEY = "domainHash";
1515
String HEADER_OPEN_STABLE_DOMAIN = "openStableDomain";
16-
String SDK_VERSION = "1.0.5.0";
16+
String SDK_VERSION = "1.0.6.0";
1717
/**
1818
* 预置域名列表
1919
*/
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.getui.push.v2.sdk.dto.req.message;
2+
3+
public class CustomBean {
4+
/**
5+
* 消息类型
6+
* subscribe:授权订阅消息(仅支持toSingle推送API)
7+
* form_update:卡片刷新消息(仅支持toSingle推送API)
8+
* live_view:实况窗消息
9+
* voip_call:VoIP呼叫消息
10+
*/
11+
private String type;
12+
/**
13+
* 相应消息类型指定请求体的JSON字符串
14+
*/
15+
private String payload;
16+
17+
public String getType() {
18+
return type;
19+
}
20+
21+
public void setType(String type) {
22+
this.type = type;
23+
}
24+
25+
public String getPayload() {
26+
return payload;
27+
}
28+
29+
public void setPayload(String payload) {
30+
this.payload = payload;
31+
}
32+
33+
@Override
34+
public String toString() {
35+
return "CustomBean{" +
36+
"type='" + type + '\'' +
37+
", payload='" + payload + '\'' +
38+
'}';
39+
}
40+
}

src/main/java/com/getui/push/v2/sdk/dto/req/message/harmony/HarmonyDTO.java

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
package com.getui.push.v2.sdk.dto.req.message.harmony;
22

3+
import com.getui.push.v2.sdk.dto.req.message.CustomBean;
4+
import com.getui.push.v2.sdk.dto.req.message.android.ThirdRevokeBean;
5+
36
import java.util.HashMap;
47
import java.util.Map;
58

69
public class HarmonyDTO {
710

811
/**
9-
* 通知消息内容,与transmission 二选一,两个都填写时报错
12+
* 通知消息内容,与transmission、custom、revoke四选一,都填写时报错。
13+
* 若希望客户端离线时,直接在系统通知栏中展示通知栏消息,推荐使用此参数。
1014
*/
1115
private HarmonyNotification notification;
1216
/**
13-
* 透传消息内容,与notification 二选一,两个都填写时报错,长度 ≤ 3072
17+
* 透传消息内容,与notification、custom、revoke四选一,都填写时报错,长度 ≤ 3072字
1418
*/
1519
private String transmission;
16-
20+
/**
21+
* 自定义消息内容,与notification、custom、revoke四选一,都填写时报错。
22+
*/
23+
private Map<String, CustomBean> custom;
24+
/**
25+
* 撤回消息时使用
26+
*/
27+
private ThirdRevokeBean revoke;
1728
/**
1829
* 第三方厂商扩展内容
1930
*/
@@ -35,6 +46,22 @@ public void setTransmission(String transmission) {
3546
this.transmission = transmission;
3647
}
3748

49+
public Map<String, CustomBean> getCustom() {
50+
return custom;
51+
}
52+
53+
public void setCustom(Map<String, CustomBean> custom) {
54+
this.custom = custom;
55+
}
56+
57+
public ThirdRevokeBean getRevoke() {
58+
return revoke;
59+
}
60+
61+
public void setRevoke(ThirdRevokeBean revoke) {
62+
this.revoke = revoke;
63+
}
64+
3865
public Map<String, Map<String, Object>> getOptions() {
3966
return options;
4067
}
@@ -66,6 +93,8 @@ public String toString() {
6693
return "HarmonyDTO{" +
6794
"notification=" + notification +
6895
", transmission='" + transmission + '\'' +
96+
", custom=" + custom +
97+
", revoke=" + revoke +
6998
", options=" + options +
7099
'}';
71100
}

src/main/java/com/getui/push/v2/sdk/dto/req/message/harmony/HarmonyNotification.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,17 @@ public class HarmonyNotification {
3232
*/
3333
private String want;
3434
/**
35-
* 鸿蒙平台通知扩展消息(消息分类category参数必填,且设置“EXPRESS”,发送通知扩展消息前请先申请开通对应的消息自分类权益)
36-
* <a href="https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/push-noti-classification-0000001727885246#section0965171625420">自分类权益申请</a>
35+
* 鸿蒙平台通知扩展消息的额外数据,传递给应用的数据,应用根据数据自行处理相关逻辑
3736
*/
3837
private String payload;
3938

39+
/**
40+
* 消息覆盖使用,两条消息的notify_id相同,新的消息会覆盖老的消息
41+
* 范围:[0, 2147483647](如果要使用鸿蒙华为的消息撤回功能,此参数必填)
42+
*/
43+
@SerializedName("notify_id")
44+
private String notifyId;
45+
4046
public String getTitle() {
4147
return title;
4248
}
@@ -85,15 +91,24 @@ public void setPayload(String payload) {
8591
this.payload = payload;
8692
}
8793

94+
public String getNotifyId() {
95+
return notifyId;
96+
}
97+
98+
public void setNotifyId(String notifyId) {
99+
this.notifyId = notifyId;
100+
}
101+
88102
@Override
89103
public String toString() {
90104
return "HarmonyNotification{" +
91-
"want='" + want + '\'' +
92-
", title='" + title + '\'' +
105+
"title='" + title + '\'' +
93106
", body='" + body + '\'' +
94107
", category='" + category + '\'' +
95108
", clickType='" + clickType + '\'' +
109+
", want='" + want + '\'' +
96110
", payload='" + payload + '\'' +
111+
", notifyId='" + notifyId + '\'' +
97112
'}';
98113
}
99114
}

0 commit comments

Comments
 (0)