Skip to content

Commit 5635d3e

Browse files
committed
[TicketNo:]DTS2021091628748
[Description:]push java demo部分问题优化 [Binary Source:]NA
1 parent 46d1c78 commit 5635d3e

8 files changed

Lines changed: 45 additions & 14 deletions

File tree

src/main/java/com/huawei/push/android/AndroidNotification.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ public class AndroidNotification {
146146
@JSONField(name = "buttons")
147147
private List<Button> buttons;
148148

149+
@JSONField(name = "profile_id")
150+
private String profileId;
151+
149152
private AndroidNotification(Builder builder) {
150153
this.title = builder.title;
151154
this.body = builder.body;
@@ -221,6 +224,8 @@ private AndroidNotification(Builder builder) {
221224
} else {
222225
this.buttons = null;
223226
}
227+
228+
this.profileId = builder.profileId;
224229
}
225230

226231
/**
@@ -258,9 +263,8 @@ public void check(Notification notification) {
258263
if (this.style != null) {
259264
boolean isTrue = this.style == 0 ||
260265
this.style == 1 ||
261-
this.style == 2 ||
262266
this.style == 3;
263-
ValidatorUtils.checkArgument(isTrue, "style should be one of 0:default, 1: big text, 2: big picture");
267+
ValidatorUtils.checkArgument(isTrue, "style should be one of 0:default, 1: big text, 3: Inbox");
264268

265269
if (this.style == 1) {
266270
ValidatorUtils.checkArgument(StringUtils.isNotEmpty(this.bigTitle) && StringUtils.isNotEmpty(this.bigBody), "title and body are required when style = 1");
@@ -325,6 +329,10 @@ public void check(Notification notification) {
325329
button.check();
326330
}
327331
}
332+
333+
if (this.profileId != null) {
334+
ValidatorUtils.checkArgument(this.profileId.length() > 64, "profileId length cannot exceed 64 characters");
335+
}
328336
}
329337

330338
/**
@@ -474,6 +482,8 @@ public List<Button> getButtons() {
474482
return buttons;
475483
}
476484

485+
public String getProfileId() { return profileId; }
486+
477487
/**
478488
* builder
479489
*
@@ -524,6 +534,8 @@ public static class Builder {
524534
private List<String> inboxContent = new ArrayList<>();
525535
private List<Button> buttons = new ArrayList<Button>();
526536

537+
private String profileId;
538+
527539
private Builder() {
528540
}
529541

@@ -731,5 +743,10 @@ public Builder addAllButtons(List<Button> buttons) {
731743
public AndroidNotification build() {
732744
return new AndroidNotification(this);
733745
}
746+
747+
public Builder setProfileId(String profileId) {
748+
this.profileId = profileId;
749+
return this;
750+
}
734751
}
735752
}

src/main/java/com/huawei/push/android/BadgeNotification.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public Integer getSetNum() {
4141
}
4242

4343
public BadgeNotification(Integer addNum, String badgeClass) {
44-
this.addNum = builder().addNum;
44+
this.addNum = addNum;
4545
this.badgeClass = badgeClass;
4646
}
4747

src/main/java/com/huawei/push/apns/Alert.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ public Builder setLocKey(String locKey) {
164164
return this;
165165
}
166166

167-
public Builder AddAllLocArgs(List<String> locArgs) {
167+
public Builder addAllLocArgs(List<String> locArgs) {
168168
this.locArgs.addAll(locArgs);
169169
return this;
170170
}
171171

172-
public Builder AddLocArg(String locArg) {
172+
public Builder addLocArg(String locArg) {
173173
this.locArgs.add(locArg);
174174
return this;
175175
}

src/main/java/com/huawei/push/apns/ApnsHmsOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
public class ApnsHmsOptions {
2222
private static final int TEST_USER = 1;
23-
private static final int FORMAL_USER = 1;
24-
private static final int VOIP_USER = 1;
23+
private static final int FORMAL_USER = 2;
24+
private static final int VOIP_USER = 3;
2525

2626
@JSONField(name = "target_user_type")
2727
private Integer targetUserType;

src/main/java/com/huawei/push/message/AndroidConfig.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public class AndroidConfig {
4949
@JSONField(name = "notification")
5050
private AndroidNotification notification;
5151

52+
@JSONField(name = "receipt_id")
53+
private String receiptId;
54+
5255
public AndroidConfig(Builder builder) {
5356
this.collapseKey = builder.collapseKey;
5457
this.urgency = builder.urgency;
@@ -64,6 +67,7 @@ public AndroidConfig(Builder builder) {
6467
this.fastAppTargetType = builder.fastAppTargetType;
6568
this.data = builder.data;
6669
this.notification = builder.notification;
70+
this.receiptId = builder.receiptId;
6771
}
6872

6973
/**
@@ -130,6 +134,8 @@ public String getData() {
130134
return data;
131135
}
132136

137+
public String getReceiptId() { return receiptId; }
138+
133139
/**
134140
* builder
135141
*/
@@ -147,6 +153,7 @@ public static class Builder {
147153
private String data;
148154

149155
private AndroidNotification notification;
156+
private String receiptId;
150157

151158
private Builder() {
152159
}
@@ -197,5 +204,10 @@ public Builder setNotification(AndroidNotification notification) {
197204
public AndroidConfig build() {
198205
return new AndroidConfig(this);
199206
}
207+
208+
public Builder setReceiptId(String receiptId) {
209+
this.receiptId = receiptId;
210+
return this;
211+
}
200212
}
201213
}

src/main/java/com/huawei/push/message/Message.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ public void check() {
8484

8585
ValidatorUtils.checkArgument(count == 1, "Exactly one of token, topic or condition must be specified");
8686

87-
boolean isEmptyData = StringUtils.isEmpty(data);
88-
8987
if (this.notification != null) {
9088
this.notification.check();
9189
}

src/main/java/com/huawei/push/util/ResponceCodeProcesser.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ public class ResponceCodeProcesser {
3232
put(80100004, "TTL is less than current time, please check");
3333
put(80100013, "Collapse_key is illegal, please check");
3434
put(80100016, "Message contians sensitive information, please check");
35+
put(80100017, "A maximum of 100 topic-based messages can be sent at the same time.");
36+
put(80100018, "Invalid message body");
3537
put(80200001, "Oauth authentication error");
3638
put(80200003, "Oauth Token expired");
3739
put(80300002, "APP is forbidden to send");
3840
put(80300007, "Invalid Token");
3941
put(80300008, "The message body size exceeds the default value set by the system (4K)");
4042
put(80300010, "Tokens exceed the default value");
43+
put(80300011, "No permission to send high-level notification messages");
44+
put(80600003, "Request OAuth service failed");
4145
put(81000001, "System inner error");
4246
put(82000001, "GroupKey or groupName error");
4347
put(82000002, "GroupKey and groupName do not match");

src/main/java/com/huawei/push/webpush/WebNotification.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class WebNotification {
5151
private String dir;
5252

5353
@JSONField(name = "vibrate")
54-
private List<Object> vibrate = new ArrayList<Object>();
54+
private List<Integer> vibrate = new ArrayList<>();
5555

5656
@JSONField(name = "renotify")
5757
private boolean renotify;
@@ -100,7 +100,7 @@ public String getDir() {
100100
return dir;
101101
}
102102

103-
public List<Object> getVibrate() {
103+
public List<Integer> getVibrate() {
104104
return vibrate;
105105
}
106106

@@ -177,7 +177,7 @@ public static class Builder {
177177
private String tag;
178178
private String badge;
179179
private String dir;
180-
private List<Object> vibrate = new ArrayList<Object>();
180+
private List<Integer> vibrate = new ArrayList<>();
181181
private boolean renotify;
182182
private boolean requireInteraction;
183183
private boolean silent;
@@ -224,12 +224,12 @@ public Builder setDir(String dir) {
224224
return this;
225225
}
226226

227-
public Builder addAllVibrate(List<Object> vibrate) {
227+
public Builder addAllVibrate(List<Integer> vibrate) {
228228
this.vibrate.addAll(vibrate);
229229
return this;
230230
}
231231

232-
public Builder addVibrate(Object vibrate) {
232+
public Builder addVibrate(Integer vibrate) {
233233
this.vibrate.add(vibrate);
234234
return this;
235235
}

0 commit comments

Comments
 (0)