From 6fc251fad2416472a58ca0b8017f633513fa4c1a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: 2020年10月13日 06:48:30 +0000 Subject: [PATCH 01/39] Bump junit from 4.11 to 4.13.1 Bumps [junit](https://github.com/junit-team/junit4) from 4.11 to 4.13.1. - [Release notes](https://github.com/junit-team/junit4/releases) - [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.11.md) - [Commits](https://github.com/junit-team/junit4/compare/r4.11...r4.13.1) Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fdc07020..1c8b07ba 100644 --- a/pom.xml +++ b/pom.xml @@ -108,7 +108,7 @@ junit junit - 4.11 + 4.13.1 test From 4a3b7d004fb561166434443e54611c009fd4ea99 Mon Sep 17 00:00:00 2001 From: huanglh Date: 2021年9月24日 18:53:52 +0800 Subject: [PATCH 02/39] add MessageDetailsResult --- .../java/cn/jpush/api/image/ImageClient.java | 6 ++---- .../jpush/api/report/MessageDetailResult.java | 2 ++ .../api/report/MessageDetailsResultTest.java | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/test/java/cn/jpush/api/report/MessageDetailsResultTest.java diff --git a/src/main/java/cn/jpush/api/image/ImageClient.java b/src/main/java/cn/jpush/api/image/ImageClient.java index 0ec491f2..15e4e679 100644 --- a/src/main/java/cn/jpush/api/image/ImageClient.java +++ b/src/main/java/cn/jpush/api/image/ImageClient.java @@ -82,8 +82,7 @@ public ImageUploadResult uploadImage(ImageUrlPayload imageUrlPayload) * @throws APIConnectionException connect exception * @throws APIRequestException request exception */ - public ImageUploadResult uploadImage(ImageFilePayload imageFilePayload) - throws APIConnectionException, APIRequestException{ + public ImageUploadResult uploadImage(ImageFilePayload imageFilePayload) { Preconditions.checkArgument(imageFilePayload.getImageType() != null, "Image type should not be null"); checkImageFilePayload(imageFilePayload); NativeHttpClient client = (NativeHttpClient) _httpClient; @@ -142,8 +141,7 @@ public ImageUploadResult modifyImage(String mediaId, ImageUrlPayload imageUrlPay * @throws APIConnectionException connection exception * @throws APIRequestException request exception */ - public ImageUploadResult modifyImage(String mediaId, ImageFilePayload imageFilePayload) - throws APIConnectionException, APIRequestException { + public ImageUploadResult modifyImage(String mediaId, ImageFilePayload imageFilePayload) { Preconditions.checkArgument(StringUtils.isNotEmpty(mediaId), "mediaId should not be empty"); checkImageFilePayload(imageFilePayload); NativeHttpClient client = (NativeHttpClient) _httpClient; diff --git a/src/main/java/cn/jpush/api/report/MessageDetailResult.java b/src/main/java/cn/jpush/api/report/MessageDetailResult.java index 942bfef8..7fe5b6f5 100644 --- a/src/main/java/cn/jpush/api/report/MessageDetailResult.java +++ b/src/main/java/cn/jpush/api/report/MessageDetailResult.java @@ -28,6 +28,8 @@ public static class Received { @Expose public JsonObject android_pns; @Expose + public JsonObject details; + @Expose public IosDetail ios; @Expose public WinphoeDetail winphone; diff --git a/src/test/java/cn/jpush/api/report/MessageDetailsResultTest.java b/src/test/java/cn/jpush/api/report/MessageDetailsResultTest.java new file mode 100644 index 00000000..995b233b --- /dev/null +++ b/src/test/java/cn/jpush/api/report/MessageDetailsResultTest.java @@ -0,0 +1,17 @@ +package cn.jpush.api.report; + +import cn.jpush.api.BaseTest; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +public class MessageDetailsResultTest extends BaseTest { + + @Test + public void getMessageDetailsResultTest() throws Exception{ + MessageDetailResult result = jpushClient.getMessagesDetail("38280845540235675"); + assertTrue(result.isResultOK()); + System.out.println(result.received_list.get(0).details); + assertTrue(result.received_list.size()> 0); + } +} From 0e7f49f1c9c7efdde961648bf6806e362c8ce34a Mon Sep 17 00:00:00 2001 From: huanglh Date: 2021年9月24日 19:04:29 +0800 Subject: [PATCH 03/39] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8F=8F=E8=BF=B0?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=96=B0=E5=A2=9E=E4=B8=80=E4=B8=AA=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=203.5.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 65d76ebb..b7328117 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.5.2 + 3.5.3 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client From 96fb6a9ed9fc43b5c4b8a68cb4ae70c9efe9f00a Mon Sep 17 00:00:00 2001 From: huanglh Date: 2021年9月24日 19:32:58 +0800 Subject: [PATCH 04/39] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cn/jpush/api/image/ImageClient.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/cn/jpush/api/image/ImageClient.java b/src/main/java/cn/jpush/api/image/ImageClient.java index 15e4e679..eb36eb8f 100644 --- a/src/main/java/cn/jpush/api/image/ImageClient.java +++ b/src/main/java/cn/jpush/api/image/ImageClient.java @@ -138,8 +138,6 @@ public ImageUploadResult modifyImage(String mediaId, ImageUrlPayload imageUrlPay * @param mediaId media id * @param imageFilePayload image file payload * @return {@link ImageUploadResult} - * @throws APIConnectionException connection exception - * @throws APIRequestException request exception */ public ImageUploadResult modifyImage(String mediaId, ImageFilePayload imageFilePayload) { Preconditions.checkArgument(StringUtils.isNotEmpty(mediaId), "mediaId should not be empty"); @@ -179,4 +177,4 @@ private void checkImageFilePayload(ImageFilePayload imageFilePayload) { } -} +} \ No newline at end of file From 75ec045bb744f4034362a334209bc3d6c3355d17 Mon Sep 17 00:00:00 2001 From: huanglh Date: 2021年9月24日 19:38:37 +0800 Subject: [PATCH 05/39] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cn/jpush/api/image/ImageClient.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/cn/jpush/api/image/ImageClient.java b/src/main/java/cn/jpush/api/image/ImageClient.java index eb36eb8f..c0ea4b4c 100644 --- a/src/main/java/cn/jpush/api/image/ImageClient.java +++ b/src/main/java/cn/jpush/api/image/ImageClient.java @@ -79,8 +79,6 @@ public ImageUploadResult uploadImage(ImageUrlPayload imageUrlPayload) * Upload image by file. Require at least 1 non-null fileName. Currently only support Xiaomi and OPPO * @param imageFilePayload image file payload * @return {@link ImageUploadResult} - * @throws APIConnectionException connect exception - * @throws APIRequestException request exception */ public ImageUploadResult uploadImage(ImageFilePayload imageFilePayload) { Preconditions.checkArgument(imageFilePayload.getImageType() != null, "Image type should not be null"); From 468184fd8c5bb507d101f9430a2cdb168ddd74b5 Mon Sep 17 00:00:00 2001 From: huanglh Date: 2021年10月18日 19:06:44 +0800 Subject: [PATCH 06/39] =?UTF-8?q?TS-6286=20=E4=BF=AE=E5=A4=8Dalert=5Ftype?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/notification/AndroidNotification.java | 2 +- .../java/cn/jpush/api/push/PushClientTest.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/cn/jpush/api/push/model/notification/AndroidNotification.java b/src/main/java/cn/jpush/api/push/model/notification/AndroidNotification.java index 79f41875..5cbac1e8 100644 --- a/src/main/java/cn/jpush/api/push/model/notification/AndroidNotification.java +++ b/src/main/java/cn/jpush/api/push/model/notification/AndroidNotification.java @@ -193,7 +193,7 @@ public JsonElement toJSON() { json.add(STYLE, new JsonPrimitive(this.style)); } - if (-1 != alert_type) { + if (-1 != alert_type && alert_type <= 7) { json.add(ALERT_TYPE, new JsonPrimitive(this.alert_type)); } diff --git a/src/test/java/cn/jpush/api/push/PushClientTest.java b/src/test/java/cn/jpush/api/push/PushClientTest.java index e67239ab..9da4c23b 100644 --- a/src/test/java/cn/jpush/api/push/PushClientTest.java +++ b/src/test/java/cn/jpush/api/push/PushClientTest.java @@ -216,4 +216,19 @@ private static PushPayload buildPushObject_android_cid() { .build(); } + @Test + public void testAlertType(){ + Notification notification = Notification.newBuilder() + .addPlatformNotification(AndroidNotification.newBuilder() + .setAlert("android内容") + .setTitle("android标题") + .setAlertType(-1) + .addCustom("uri_activity","uri_activity") + .addCustom("uri_action","uri_action") + .addExtra("a","a") + .build() + ).build(); + System.out.println(notification.toJSON()); + } + } From 4d4dc0fecc56a526ede4546f0188f7be3672cbb6 Mon Sep 17 00:00:00 2001 From: huanglh Date: 2021年10月18日 19:24:01 +0800 Subject: [PATCH 07/39] v3.5.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b7328117..d4be8307 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.5.3 + 3.5.4 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client From 687ac3477cd97bca9b620d7012ceef953127ac28 Mon Sep 17 00:00:00 2001 From: huanglh Date: 2021年10月27日 18:58:28 +0800 Subject: [PATCH 08/39] =?UTF-8?q?=E6=9B=B4=E6=96=B0jiguang-common=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E8=87=B31.1.12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d4be8307..528b0675 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ cn.jpush.api jiguang-common - 1.1.11 + 1.1.12 org.apache.httpcomponents From 6143432d8c86608350a31959c38e2dbd7497eee4 Mon Sep 17 00:00:00 2001 From: huanglh Date: 2021年10月27日 18:59:39 +0800 Subject: [PATCH 09/39] v3.5.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 528b0675..7316ba4f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.5.4 + 3.5.5 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client From 099f7fead5bf0253942520c50e1ad82af95b6230 Mon Sep 17 00:00:00 2001 From: huanglh Date: 2021年12月31日 16:38:56 +0800 Subject: [PATCH 10/39] =?UTF-8?q?jdk=E6=94=AF=E6=8C=81=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA1.6=E4=BB=A5=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 8 ++++---- src/main/java/cn/jpush/api/admin/AdminClient.java | 4 ++-- src/main/java/cn/jpush/api/file/FileClient.java | 2 +- src/main/java/cn/jpush/api/image/ImageClient.java | 2 +- .../cn/jpush/api/image/model/ImageFilePayload.java | 2 +- src/main/java/cn/jpush/api/push/model/Message.java | 8 ++++---- src/main/java/cn/jpush/api/push/model/Options.java | 14 +++++++------- .../java/cn/jpush/api/push/model/PushPayload.java | 2 +- .../cn/jpush/api/push/model/audience/Audience.java | 2 +- .../api/push/model/audience/AudienceTarget.java | 2 +- .../model/notification/PlatformNotification.java | 4 ++-- .../jpush/api/report/GroupMessageDetailResult.java | 2 +- src/test/java/cn/jpush/api/BaseTest.java | 4 ++-- .../jpush/api/device/DeviceNormalRemoteTest.java | 2 +- .../java/cn/jpush/api/image/ImageClientTest.java | 6 +++--- .../java/cn/jpush/api/push/model/OptionsTest.java | 6 +++--- .../notification/AndroidNotificationTest.java | 3 +-- 17 files changed, 36 insertions(+), 37 deletions(-) diff --git a/pom.xml b/pom.xml index 7316ba4f..e8293ffb 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.5.5 + 3.6.0 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client @@ -20,8 +20,8 @@ github UTF-8 - 1.7 - 1.7 + 1.6 + 1.6 @@ -51,7 +51,7 @@ cn.jpush.api jiguang-common - 1.1.12 + 1.2.0 org.apache.httpcomponents diff --git a/src/main/java/cn/jpush/api/admin/AdminClient.java b/src/main/java/cn/jpush/api/admin/AdminClient.java index 040b791b..57bce1c2 100644 --- a/src/main/java/cn/jpush/api/admin/AdminClient.java +++ b/src/main/java/cn/jpush/api/admin/AdminClient.java @@ -115,8 +115,8 @@ public void uploadCertificate(String appKey, String devCertificateFile, String d NativeHttpClient client = (NativeHttpClient) mHttpClient; String url = mBasePath + mV1AppPath + "/" + appKey + "/certificate"; - Map fileMap = new HashMap(); - Map textMap = new HashMap(); + Map fileMap = new HashMap(); + Map textMap = new HashMap(); if(devCertificateFile != null) { textMap.put("devCertificatePassword", devCertificatePassword); diff --git a/src/main/java/cn/jpush/api/file/FileClient.java b/src/main/java/cn/jpush/api/file/FileClient.java index ac38257d..a07d91f4 100644 --- a/src/main/java/cn/jpush/api/file/FileClient.java +++ b/src/main/java/cn/jpush/api/file/FileClient.java @@ -53,7 +53,7 @@ public FileUploadResult uploadFile(FileType type, String filename) NativeHttpClient client = (NativeHttpClient) _httpClient; String typeStr = type.value(); String url = _baseUrl + _filesPath + "/" + typeStr; - Map fileMap = new HashMap(); + Map fileMap = new HashMap(); fileMap.put("filename", filename); String response = client.formUploadByPost(url, null, fileMap, null); LOG.info("uploadFile:{}", response); diff --git a/src/main/java/cn/jpush/api/image/ImageClient.java b/src/main/java/cn/jpush/api/image/ImageClient.java index c0ea4b4c..101f78c7 100644 --- a/src/main/java/cn/jpush/api/image/ImageClient.java +++ b/src/main/java/cn/jpush/api/image/ImageClient.java @@ -86,7 +86,7 @@ public ImageUploadResult uploadImage(ImageFilePayload imageFilePayload) { NativeHttpClient client = (NativeHttpClient) _httpClient; String url = _baseUrl + _imagesPath + "/" + ImageSource.FILE.value(); - Map textMap = new HashMap(); + Map textMap = new HashMap(); textMap.put("image_type", String.valueOf(imageFilePayload.getImageType().value())); Map fileMap = imageFilePayload.toFileMap(); diff --git a/src/main/java/cn/jpush/api/image/model/ImageFilePayload.java b/src/main/java/cn/jpush/api/image/model/ImageFilePayload.java index 7a4be086..f8143484 100644 --- a/src/main/java/cn/jpush/api/image/model/ImageFilePayload.java +++ b/src/main/java/cn/jpush/api/image/model/ImageFilePayload.java @@ -22,7 +22,7 @@ public class ImageFilePayload { private String jiguangFileName; public Map toFileMap() { - HashMap fileMap = new HashMap(); + HashMap fileMap = new HashMap(); if (null != oppoFileName) { fileMap.put(OPPO_IMAGE_FILE, oppoFileName); } diff --git a/src/main/java/cn/jpush/api/push/model/Message.java b/src/main/java/cn/jpush/api/push/model/Message.java index e57c5641..822f8a74 100644 --- a/src/main/java/cn/jpush/api/push/model/Message.java +++ b/src/main/java/cn/jpush/api/push/model/Message.java @@ -188,7 +188,7 @@ public Builder addExtra(String key, JsonObject value) { public Builder addCustom(Map extras) { if (customData == null) { - customData = new LinkedHashMap(); + customData = new LinkedHashMap(); } for (Map.Entry entry : extras.entrySet()) { customData.put(entry.getKey(), new JsonPrimitive(entry.getValue())); @@ -199,7 +199,7 @@ public Builder addCustom(Map extras) { public Builder addCustom(String key, Number value) { Preconditions.checkArgument(!(null == key), "Key should not be null."); if (customData == null) { - customData = new LinkedHashMap(); + customData = new LinkedHashMap(); } customData.put(key, new JsonPrimitive(value)); return this; @@ -208,7 +208,7 @@ public Builder addCustom(String key, Number value) { public Builder addCustom(String key, String value) { Preconditions.checkArgument(!(null == key), "Key should not be null."); if (customData == null) { - customData = new LinkedHashMap(); + customData = new LinkedHashMap(); } customData.put(key, new JsonPrimitive(value)); return this; @@ -217,7 +217,7 @@ public Builder addCustom(String key, String value) { public Builder addCustom(String key, Boolean value) { Preconditions.checkArgument(!(null == key), "Key should not be null."); if (customData == null) { - customData = new LinkedHashMap(); + customData = new LinkedHashMap(); } customData.put(key, new JsonPrimitive(value)); return this; diff --git a/src/main/java/cn/jpush/api/push/model/Options.java b/src/main/java/cn/jpush/api/push/model/Options.java index 0e0f07e6..f1208974 100644 --- a/src/main/java/cn/jpush/api/push/model/Options.java +++ b/src/main/java/cn/jpush/api/push/model/Options.java @@ -194,12 +194,12 @@ public Builder setBigPushDuration(int bigPushDuration) { @Deprecated public Map> getThirdPartyChannel() { if (null != thirdPartyChannel) { - Map> thirdPartyChannelRsp = new HashMap(); + Map> thirdPartyChannelRsp = new HashMap>(); Set
    > entrySet = thirdPartyChannel.entrySet(); for (Map.Entry entry : entrySet) { JsonObject entryValue = entry.getValue(); Set
      > valueEntrySet = entryValue.entrySet(); - Map valueMap = new HashMap(); + Map valueMap = new HashMap(); for (Map.Entry valueEntry : valueEntrySet) { valueMap.put(valueEntry.getKey(), null == valueEntry.getValue() ? null : valueEntry.getValue().getAsString()); } @@ -212,7 +212,7 @@ public Map> getThirdPartyChannel() { @Deprecated public Builder setThirdPartyChannel(Map> thirdPartyChannel) { - this.thirdPartyChannel = new HashMap(); + this.thirdPartyChannel = new HashMap(); if (null != thirdPartyChannel) { Set
        >> entrySet = thirdPartyChannel.entrySet(); for (Map.Entry> entry : entrySet) { @@ -239,7 +239,7 @@ public Builder setThirdPartyChannelV2(Map thirdPartyChannel) public Builder addCustom(Map extras) { if (customData == null) { - customData = new LinkedHashMap(); + customData = new LinkedHashMap(); } for (Map.Entry entry : extras.entrySet()) { customData.put(entry.getKey(), new JsonPrimitive(entry.getValue())); @@ -250,7 +250,7 @@ public Builder addCustom(Map extras) { public Builder addCustom(String key, Number value) { Preconditions.checkArgument(! (null == key), "Key should not be null."); if (customData == null) { - customData = new LinkedHashMap(); + customData = new LinkedHashMap(); } customData.put(key, new JsonPrimitive(value)); return this; @@ -259,7 +259,7 @@ public Builder addCustom(String key, Number value) { public Builder addCustom(String key, String value) { Preconditions.checkArgument(! (null == key), "Key should not be null."); if (customData == null) { - customData = new LinkedHashMap(); + customData = new LinkedHashMap(); } customData.put(key, new JsonPrimitive(value)); return this; @@ -268,7 +268,7 @@ public Builder addCustom(String key, String value) { public Builder addCustom(String key, Boolean value) { Preconditions.checkArgument(! (null == key), "Key should not be null."); if (customData == null) { - customData = new LinkedHashMap(); + customData = new LinkedHashMap(); } customData.put(key, new JsonPrimitive(value)); return this; diff --git a/src/main/java/cn/jpush/api/push/model/PushPayload.java b/src/main/java/cn/jpush/api/push/model/PushPayload.java index 9ab26205..e3030924 100644 --- a/src/main/java/cn/jpush/api/push/model/PushPayload.java +++ b/src/main/java/cn/jpush/api/push/model/PushPayload.java @@ -284,7 +284,7 @@ public static class Builder { private Map custom; public Builder() { - this.custom = new LinkedHashMap(); + this.custom = new LinkedHashMap(); } public Builder setTarget(String target) { diff --git a/src/main/java/cn/jpush/api/push/model/audience/Audience.java b/src/main/java/cn/jpush/api/push/model/audience/Audience.java index 1707bdd3..3aad28c9 100644 --- a/src/main/java/cn/jpush/api/push/model/audience/Audience.java +++ b/src/main/java/cn/jpush/api/push/model/audience/Audience.java @@ -145,7 +145,7 @@ public static Audience fromJsonElement(JsonElement jsonElement) { } boolean file = false; JsonObject jsonObject = jsonElement.getAsJsonObject(); - Set audienceTargetSet = new HashSet(); + Set audienceTargetSet = new HashSet(); for (AudienceType type : AudienceType.values()) { JsonArray jsonArray = jsonObject.getAsJsonArray(type.value()); if (jsonArray == null) { diff --git a/src/main/java/cn/jpush/api/push/model/audience/AudienceTarget.java b/src/main/java/cn/jpush/api/push/model/audience/AudienceTarget.java index 527dd908..47b6f4e5 100644 --- a/src/main/java/cn/jpush/api/push/model/audience/AudienceTarget.java +++ b/src/main/java/cn/jpush/api/push/model/audience/AudienceTarget.java @@ -114,7 +114,7 @@ public JsonElement toFileJSON() { } public static AudienceTarget fromJsonElement(JsonArray jsonArray, AudienceType type) { - Set stringSet = new HashSet(); + Set stringSet = new HashSet(); if (jsonArray != null) { for (int i=0; i extras, this.numberExtras = numberExtras; this.booleanExtras = booleanExtras; this.jsonExtras = jsonExtras; - customData = new LinkedHashMap(); + customData = new LinkedHashMap(); } public PlatformNotification(Object alert, Map extras, @@ -142,7 +142,7 @@ protected abstract static class Builder customData; public Builder () { - customData = new LinkedHashMap(); + customData = new LinkedHashMap(); theBuilder = getThis(); } diff --git a/src/main/java/cn/jpush/api/report/GroupMessageDetailResult.java b/src/main/java/cn/jpush/api/report/GroupMessageDetailResult.java index 155f1377..1f380f71 100644 --- a/src/main/java/cn/jpush/api/report/GroupMessageDetailResult.java +++ b/src/main/java/cn/jpush/api/report/GroupMessageDetailResult.java @@ -19,7 +19,7 @@ public class GroupMessageDetailResult extends BaseResult { private static final Type RECEIVED_TYPE = new TypeToken>() {}.getType(); @Expose - public List received_list = new ArrayList(); + public List received_list = new ArrayList(); public static class Received { @Expose diff --git a/src/test/java/cn/jpush/api/BaseTest.java b/src/test/java/cn/jpush/api/BaseTest.java index 14aebb88..030f65c1 100644 --- a/src/test/java/cn/jpush/api/BaseTest.java +++ b/src/test/java/cn/jpush/api/BaseTest.java @@ -4,8 +4,8 @@ public abstract class BaseTest { - protected static final String APP_KEY = "d4ee2375846bc30fa51334f5"; - protected static final String MASTER_SECRET = "3f045fd404d09a8a1f38d791"; + protected static final String APP_KEY = "eb67142502ec9f5556875b9a"; + protected static final String MASTER_SECRET = "186aa57bc697c94f8698bbbf"; protected static final String GROUP_MASTER_SECRET = "b11314807507e2bcfdeebe2e"; protected static final String GROUP_PUSH_KEY = "2c88a01e073a0fe4fc7b167c"; diff --git a/src/test/java/cn/jpush/api/device/DeviceNormalRemoteTest.java b/src/test/java/cn/jpush/api/device/DeviceNormalRemoteTest.java index 23197e31..701aa501 100644 --- a/src/test/java/cn/jpush/api/device/DeviceNormalRemoteTest.java +++ b/src/test/java/cn/jpush/api/device/DeviceNormalRemoteTest.java @@ -200,7 +200,7 @@ public void testBindMobile_empty() throws APIConnectionException, APIRequestExce @Test @TestOrder(order = 330) public void testRemoveDevicesFromAlias() throws APIConnectionException, APIRequestException { - Set toRemoveDevice = new HashSet(); + Set toRemoveDevice = new HashSet(); toRemoveDevice.add(REGISTRATION_ID1); DefaultResult result = jpushClient.removeDevicesFromAlias("alias1", toRemoveDevice); assertTrue(result.isResultOK()); diff --git a/src/test/java/cn/jpush/api/image/ImageClientTest.java b/src/test/java/cn/jpush/api/image/ImageClientTest.java index 849a2322..8999ce5d 100644 --- a/src/test/java/cn/jpush/api/image/ImageClientTest.java +++ b/src/test/java/cn/jpush/api/image/ImageClientTest.java @@ -73,9 +73,9 @@ public void testUploadImageByFile() throws NoSuchFieldException { .setXiaomiFileName("dir/xiaomiXX.jpg") .build(); ImageUploadResult imageUploadResult = spyClient.uploadImage(payload); - HashMap textMap = new HashMap(); + HashMap textMap = new HashMap(); textMap.put("image_type", "2"); - HashMap fileMap = new HashMap(); + HashMap fileMap = new HashMap(); fileMap.put("oppo_file", "oppoXX.jpg"); fileMap.put("xiaomi_file", "dir/xiaomiXX.jpg"); verify(mockIHttpClient).formUploadByPost("https://api.jpush.cn/v3/images/byfiles", textMap, fileMap, null); @@ -136,7 +136,7 @@ public void testModifyImageByFile() throws NoSuchFieldException { .setXiaomiFileName("dir/xiaomiXX.jpg") .build(); ImageUploadResult imageUploadResult = spyClient.modifyImage(mediaId, payload); - HashMap fileMap = new HashMap(); + HashMap fileMap = new HashMap(); fileMap.put("oppo_file", "oppoXX.jpg"); fileMap.put("xiaomi_file", "dir/xiaomiXX.jpg"); verify(mockIHttpClient).formUploadByPut("https://api.jpush.cn/v3/images/byfiles/" + mediaId, null, fileMap, null); diff --git a/src/test/java/cn/jpush/api/push/model/OptionsTest.java b/src/test/java/cn/jpush/api/push/model/OptionsTest.java index 09356610..e36dd9d1 100644 --- a/src/test/java/cn/jpush/api/push/model/OptionsTest.java +++ b/src/test/java/cn/jpush/api/push/model/OptionsTest.java @@ -136,8 +136,8 @@ public void testBigPushDuration() { public void testThirdPartyChannel() { int sendno = ServiceHelper.generateSendno(); - Map> thirdMap = new HashMap(); - Map huaweiMap = new HashMap(); + Map> thirdMap = new HashMap>(); + Map huaweiMap = new HashMap(); huaweiMap.put("distribution", "jpush"); thirdMap.put("huawei", huaweiMap); @@ -163,7 +163,7 @@ public void testThirdPartyChannel() { public void testThirdPartyChannelV2() { int sendno = ServiceHelper.generateSendno(); - Map thirdMap = new HashMap(); + Map thirdMap = new HashMap(); JsonObject vivoJsonObj = new JsonObject(); vivoJsonObj.addProperty("distribution", "ospush"); vivoJsonObj.addProperty("classification", 1); diff --git a/src/test/java/cn/jpush/api/push/model/notification/AndroidNotificationTest.java b/src/test/java/cn/jpush/api/push/model/notification/AndroidNotificationTest.java index 460c2cb2..c3748e4c 100644 --- a/src/test/java/cn/jpush/api/push/model/notification/AndroidNotificationTest.java +++ b/src/test/java/cn/jpush/api/push/model/notification/AndroidNotificationTest.java @@ -11,7 +11,6 @@ import java.util.HashMap; import java.util.Map; -import java.util.Objects; @Category(FastTests.class) public class AndroidNotificationTest { @@ -68,7 +67,7 @@ public void testExtra_nullvalue() { @Test public void testCustomParam() { - Map customParams = new HashMap(); + Map customParams = new HashMap(); customParams.put("custom_field1", "field1"); customParams.put("custom_field2", "field2"); customParams.put("custom_field3", "field3"); From 9b1dc3521f1fbedcd8b744f079497e1cf063dfad Mon Sep 17 00:00:00 2001 From: huanglh Date: 2022年1月24日 10:44:38 +0800 Subject: [PATCH 11/39] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=96=B0=E5=A2=9Ettl=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- src/main/java/cn/jpush/api/file/FileClient.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index e8293ffb..2062ad7e 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.6.0 + 3.6.1 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client diff --git a/src/main/java/cn/jpush/api/file/FileClient.java b/src/main/java/cn/jpush/api/file/FileClient.java index a07d91f4..0a460bca 100644 --- a/src/main/java/cn/jpush/api/file/FileClient.java +++ b/src/main/java/cn/jpush/api/file/FileClient.java @@ -46,15 +46,17 @@ public FileClient(String masterSecret, String appKey, HttpProxy proxy, ClientCon this._httpClient = new NativeHttpClient(authCode, proxy, conf); } - public FileUploadResult uploadFile(FileType type, String filename) + public FileUploadResult uploadFile(FileType type, String filename, Integer ttl) throws APIConnectionException, APIRequestException { Preconditions.checkArgument(type != null, "type should not be null"); Preconditions.checkArgument(StringUtils.isNotEmpty(filename), "filename should not be null"); + Preconditions.checkArgument(ttl>= 1 && ttl <= 720,"TTL is not in the range of 1 to 720"); NativeHttpClient client = (NativeHttpClient) _httpClient; String typeStr = type.value(); String url = _baseUrl + _filesPath + "/" + typeStr; Map fileMap = new HashMap(); fileMap.put("filename", filename); + fileMap.put("ttl",String.valueOf(ttl)); String response = client.formUploadByPost(url, null, fileMap, null); LOG.info("uploadFile:{}", response); return _gson.fromJson(response, @@ -62,6 +64,10 @@ public FileUploadResult uploadFile(FileType type, String filename) }.getType()); } + public FileUploadResult uploadFile(FileType type, String filename) throws APIConnectionException, APIRequestException { + return uploadFile(type,filename,720); + } + public FileModelPage queryEffectFiles() throws APIConnectionException, APIRequestException { String url = _baseUrl + _filesPath + "/"; ResponseWrapper response = _httpClient.sendGet(url); From ad4fdb8ab643a226a44b53fec0137c4302aa28e1 Mon Sep 17 00:00:00 2001 From: huanglh Date: 2022年1月24日 19:59:43 +0800 Subject: [PATCH 12/39] =?UTF-8?q?PC-5108=20=E4=BF=AE=E5=A4=8D=E6=96=B0?= =?UTF-8?q?=E7=94=9F=E6=88=90JPushClient=E4=BC=9A=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E5=85=AC=E6=9C=89=E4=BA=91=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cn/jpush/api/push/PushClient.java | 4 ++++ src/main/java/cn/jpush/api/schedule/ScheduleClient.java | 5 ++++- src/test/java/cn/jpush/api/schedule/ScheduleClientTest.java | 6 ++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/cn/jpush/api/push/PushClient.java b/src/main/java/cn/jpush/api/push/PushClient.java index e0262406..4a572d88 100644 --- a/src/main/java/cn/jpush/api/push/PushClient.java +++ b/src/main/java/cn/jpush/api/push/PushClient.java @@ -57,6 +57,10 @@ public PushClient(String masterSecret, String appKey) { this(masterSecret, appKey, null, ClientConfig.getInstance()); } + public PushClient(String masterSecret, String appKey,ClientConfig clientConfig){ + this(masterSecret,appKey,null,clientConfig); + } + /** * This will be removed in the future. Please use ClientConfig{jiguang-common cn.jiguang.common.ClientConfig} instead of this constructor. * diff --git a/src/main/java/cn/jpush/api/schedule/ScheduleClient.java b/src/main/java/cn/jpush/api/schedule/ScheduleClient.java index ec7514d5..baabf014 100644 --- a/src/main/java/cn/jpush/api/schedule/ScheduleClient.java +++ b/src/main/java/cn/jpush/api/schedule/ScheduleClient.java @@ -23,6 +23,8 @@ public class ScheduleClient { private String hostName; private String schedulePath; + private PushClient pushClient; + // If not present, true by default. private int apnsProduction; @@ -81,6 +83,8 @@ public ScheduleClient(String masterSecret, String appKey, HttpProxy proxy, Clien schedulePath = (String) conf.get(ClientConfig.SCHEDULE_PATH); apnsProduction = (Integer) conf.get(ClientConfig.APNS_PRODUCTION); timeToLive = (Long) conf.get(ClientConfig.TIME_TO_LIVE); + //createSchedule接口需要用到这个类 + pushClient = new PushClient(masterSecret, appKey, ClientConfig.getInstance()); String authCode = ServiceHelper.getBasicAuthorization(appKey, masterSecret); this._httpClient = new NativeHttpClient(authCode, proxy, conf); @@ -104,7 +108,6 @@ public ScheduleResult createSchedule(SchedulePayload payload, String masterSecre // 调用getCidList方法来获取cid并赋值到payload中 String cid = payload.getCid(); if (cid == null) { - PushClient pushClient = new PushClient(masterSecret, appKey); CIDResult cidResult = pushClient.getCidList(1 , "schedule"); payload.setCid(cidResult.cidlist.get(0)); } diff --git a/src/test/java/cn/jpush/api/schedule/ScheduleClientTest.java b/src/test/java/cn/jpush/api/schedule/ScheduleClientTest.java index 22169cfa..d9747321 100644 --- a/src/test/java/cn/jpush/api/schedule/ScheduleClientTest.java +++ b/src/test/java/cn/jpush/api/schedule/ScheduleClientTest.java @@ -60,10 +60,12 @@ public void testGetScheduleList() { * Method: deleteSchedule(String scheduleId) */ @Test - public void testScheduleMethods(String masterSecret, String appKey) { + public void testScheduleMethods() { + String masterSecret = MASTER_SECRET; + String appKey = APP_KEY; String name = "test_schedule"; TriggerPayload trigger = TriggerPayload.newBuilder() - .setSingleTime("2105-07-30 12:00:00") + .setSingleTime("2022-07-30 12:00:00") .buildSingle(); PushPayload push = PushPayload.alertAll("test schedule"); From 8cbd7254489142f88c905104ad2b784957321e20 Mon Sep 17 00:00:00 2001 From: huanglh Date: 2022年1月25日 18:50:33 +0800 Subject: [PATCH 13/39] =?UTF-8?q?=E5=B0=86clientConfig=E4=BC=A0=E7=BB=99Pu?= =?UTF-8?q?shClient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cn/jpush/api/schedule/ScheduleClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cn/jpush/api/schedule/ScheduleClient.java b/src/main/java/cn/jpush/api/schedule/ScheduleClient.java index baabf014..9d88cb57 100644 --- a/src/main/java/cn/jpush/api/schedule/ScheduleClient.java +++ b/src/main/java/cn/jpush/api/schedule/ScheduleClient.java @@ -84,7 +84,7 @@ public ScheduleClient(String masterSecret, String appKey, HttpProxy proxy, Clien apnsProduction = (Integer) conf.get(ClientConfig.APNS_PRODUCTION); timeToLive = (Long) conf.get(ClientConfig.TIME_TO_LIVE); //createSchedule接口需要用到这个类 - pushClient = new PushClient(masterSecret, appKey, ClientConfig.getInstance()); + pushClient = new PushClient(masterSecret, appKey, conf); String authCode = ServiceHelper.getBasicAuthorization(appKey, masterSecret); this._httpClient = new NativeHttpClient(authCode, proxy, conf); From 54011cab82f02db913ef9127e996e001b9ca72dc Mon Sep 17 00:00:00 2001 From: huanglh Date: 2022年3月29日 14:22:30 +0800 Subject: [PATCH 14/39] =?UTF-8?q?=E5=B0=86ttl=E6=94=BE=E5=9C=A8textMap?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cn/jpush/api/file/FileClient.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/cn/jpush/api/file/FileClient.java b/src/main/java/cn/jpush/api/file/FileClient.java index 0a460bca..da1ac10f 100644 --- a/src/main/java/cn/jpush/api/file/FileClient.java +++ b/src/main/java/cn/jpush/api/file/FileClient.java @@ -56,8 +56,9 @@ public FileUploadResult uploadFile(FileType type, String filename, Integer ttl) String url = _baseUrl + _filesPath + "/" + typeStr; Map fileMap = new HashMap(); fileMap.put("filename", filename); - fileMap.put("ttl",String.valueOf(ttl)); - String response = client.formUploadByPost(url, null, fileMap, null); + Map textMap = new HashMap(); + textMap.put("ttl",String.valueOf(ttl)); + String response = client.formUploadByPost(url, textMap, fileMap, null); LOG.info("uploadFile:{}", response); return _gson.fromJson(response, new TypeToken() { From f125df09cdc7a87e70148b120772f46f96f920db Mon Sep 17 00:00:00 2001 From: huanglh Date: 2022年3月31日 11:09:49 +0800 Subject: [PATCH 15/39] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E8=87=B33.6.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2062ad7e..9f205da3 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.6.1 + 3.6.2 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client From b47ebd9259204393970244c84b9f182143a0516d Mon Sep 17 00:00:00 2001 From: wicked-tc130 Date: 2022年6月21日 20:25:26 +0800 Subject: [PATCH 16/39] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 71269ea2..9c9d6c78 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.6.2 + 3.6.3 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client From 7ef64433760e52fb5fd85236839106d2b62c4181 Mon Sep 17 00:00:00 2001 From: wicked-tc130 Date: Wed, 6 Jul 2022 14:38:20 +0800 Subject: [PATCH 17/39] Update pom.xml update common version to 1.2.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9c9d6c78..17ce3bde 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ cn.jpush.api jiguang-common - 1.2.0 + 1.2.1 org.apache.httpcomponents From 9258a09fae5c910c4d5edd401263612b524935d5 Mon Sep 17 00:00:00 2001 From: wicked-tc130 Date: Wed, 6 Jul 2022 14:38:55 +0800 Subject: [PATCH 18/39] Update pom.xml update version to 3.6.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 17ce3bde..03b0315f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.6.3 + 3.6.4 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client From 8011a0cfeb805f51b4087ff1e86ed5ed9ba46c55 Mon Sep 17 00:00:00 2001 From: wicked-tc130 Date: Thu, 7 Jul 2022 18:38:27 +0800 Subject: [PATCH 19/39] Update pom.xml update common version to 1.2.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 03b0315f..2d477e4a 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ cn.jpush.api jiguang-common - 1.2.1 + 1.2.2 org.apache.httpcomponents From 07dd02f8c842170ebf52730c3d592965336d4fd1 Mon Sep 17 00:00:00 2001 From: wicked-tc130 Date: Thu, 7 Jul 2022 18:41:05 +0800 Subject: [PATCH 20/39] Update pom.xml update version to 3.6.5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2d477e4a..2db99667 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.6.4 + 3.6.5 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client From 1ee28b0af989b2c54dc91f1f5d77ebe1fa2845f8 Mon Sep 17 00:00:00 2001 From: wicked-tc130 Date: Thu, 7 Jul 2022 18:51:59 +0800 Subject: [PATCH 21/39] Update pom.xml update version to 3.6.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2db99667..015b96ac 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.6.5 + 3.6.6 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client From 449279836197e0f8187cafc48c8568c9595fcccc Mon Sep 17 00:00:00 2001 From: zhanq Date: 2023年5月26日 17:41:22 +0800 Subject: [PATCH 22/39] =?UTF-8?q?add=EF=BC=9A=E6=94=AF=E6=8C=81liveActivit?= =?UTF-8?q?y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- src/main/java/cn/jpush/api/JPushClient.java | 617 +++++++++--------- .../java/cn/jpush/api/push/PushClient.java | 14 +- .../model/live_activity/LiveActivity.java | 194 ++++++ .../live_activity/LiveActivityEvent.java | 24 + .../api/push/model/LiveActivityTest.java | 38 ++ 6 files changed, 590 insertions(+), 299 deletions(-) create mode 100644 src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java create mode 100644 src/main/java/cn/jpush/api/push/model/live_activity/LiveActivityEvent.java create mode 100644 src/test/java/cn/jpush/api/push/model/LiveActivityTest.java diff --git a/pom.xml b/pom.xml index 015b96ac..79beaa61 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.6.6 + 3.6.8 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client diff --git a/src/main/java/cn/jpush/api/JPushClient.java b/src/main/java/cn/jpush/api/JPushClient.java index ea4a7dd3..e0b132b7 100644 --- a/src/main/java/cn/jpush/api/JPushClient.java +++ b/src/main/java/cn/jpush/api/JPushClient.java @@ -7,6 +7,7 @@ import cn.jiguang.common.resp.*; import cn.jpush.api.push.CIDResult; import cn.jpush.api.push.model.*; +import cn.jpush.api.push.model.live_activity.LiveActivity; import cn.jpush.api.report.*; import cn.jpush.api.report.model.CheckMessagePayload; import com.google.gson.JsonObject; @@ -38,30 +39,30 @@ */ public class JPushClient { private final PushClient _pushClient; - private final ReportClient _reportClient; - private final DeviceClient _deviceClient; + private final ReportClient _reportClient; + private final DeviceClient _deviceClient; private final ScheduleClient _scheduleClient; - - /** - * Create a JPush Client. - * - * @param masterSecret API access secret of the appKey. - * @param appKey The KEY of one application on JPush. - */ - public JPushClient(String masterSecret, String appKey) { - _pushClient = new PushClient(masterSecret, appKey); - _reportClient = new ReportClient(masterSecret, appKey); - _deviceClient = new DeviceClient(masterSecret, appKey); + + /** + * Create a JPush Client. + * + * @param masterSecret API access secret of the appKey. + * @param appKey The KEY of one application on JPush. + */ + public JPushClient(String masterSecret, String appKey) { + _pushClient = new PushClient(masterSecret, appKey); + _reportClient = new ReportClient(masterSecret, appKey); + _deviceClient = new DeviceClient(masterSecret, appKey); _scheduleClient = new ScheduleClient(masterSecret, appKey); - } + } /** * Create a JPush Client by custom Client configuration. * * @param masterSecret API access secret of the appKey. - * @param appKey The KEY of one application on JPush. - * @param proxy The proxy, if there is no proxy, should be null. - * @param conf The client configuration. Can use ClientConfig.getInstance() as default. + * @param appKey The KEY of one application on JPush. + * @param proxy The proxy, if there is no proxy, should be null. + * @param conf The client configuration. Can use ClientConfig.getInstance() as default. */ public JPushClient(String masterSecret, String appKey, HttpProxy proxy, ClientConfig conf) { _pushClient = new PushClient(masterSecret, appKey, proxy, conf); @@ -72,24 +73,26 @@ public JPushClient(String masterSecret, String appKey, HttpProxy proxy, ClientCo /** * This will be removed in the future. Please use ClientConfig{jiguang-common cn.jiguang.common.ClientConfig#setMaxRetryTimes} instead of this constructor. - * @param masterSecret API access secret of the appKey. - * @param appKey The KEY of one application on JPush. + * + * @param masterSecret API access secret of the appKey. + * @param appKey The KEY of one application on JPush. * @param maxRetryTimes The max retry times. */ @Deprecated - public JPushClient(String masterSecret, String appKey, int maxRetryTimes) { + public JPushClient(String masterSecret, String appKey, int maxRetryTimes) { _pushClient = new PushClient(masterSecret, appKey, maxRetryTimes); _reportClient = new ReportClient(masterSecret, appKey, maxRetryTimes); _deviceClient = new DeviceClient(masterSecret, appKey, maxRetryTimes); _scheduleClient = new ScheduleClient(masterSecret, appKey, maxRetryTimes); - } + } /** * This will be removed in the future. Please use ClientConfig{jiguang-common cn.jiguang.common.ClientConfig#setMaxRetryTimes} instead of this constructor. - * @param masterSecret API access secret of the appKey. - * @param appKey The KEY of one application on JPush. + * + * @param masterSecret API access secret of the appKey. + * @param appKey The KEY of one application on JPush. * @param maxRetryTimes The max retry times. - * @param proxy The proxy, if there is no proxy, should be null. + * @param proxy The proxy, if there is no proxy, should be null. */ @Deprecated public JPushClient(String masterSecret, String appKey, int maxRetryTimes, HttpProxy proxy) { @@ -98,18 +101,18 @@ public JPushClient(String masterSecret, String appKey, int maxRetryTimes, HttpPr _deviceClient = new DeviceClient(masterSecret, appKey, maxRetryTimes, proxy); _scheduleClient = new ScheduleClient(masterSecret, appKey, maxRetryTimes, proxy); } - + /** * Create a JPush Client by custom Client configuration. - * + *

        * If you are using JPush privacy cloud, maybe this constructor is what you needed. * This will be removed in the future. Please use ClientConfig{jiguang-common cn.jiguang.common.ClientConfig#setMaxRetryTimes} instead of this constructor. * - * @param masterSecret API access secret of the appKey. - * @param appKey The KEY of one application on JPush. + * @param masterSecret API access secret of the appKey. + * @param appKey The KEY of one application on JPush. * @param maxRetryTimes Client request retry times. - * @param proxy The proxy, if there is no proxy, should be null. - * @param conf The client configuration. Can use ClientConfig.getInstance() as default. + * @param proxy The proxy, if there is no proxy, should be null. + * @param conf The client configuration. Can use ClientConfig.getInstance() as default. */ @Deprecated public JPushClient(String masterSecret, String appKey, int maxRetryTimes, HttpProxy proxy, ClientConfig conf) { @@ -124,18 +127,18 @@ public JPushClient(String masterSecret, String appKey, int maxRetryTimes, HttpPr /** * Create a JPush Client by custom Client configuration with global settings. - * + *

        * If you are using JPush privacy cloud, and you want different settings from default globally, * maybe this constructor is what you needed. * This will be removed in the future. Please use ClientConfig{jiguang-common cn.jiguang.common.ClientConfig#setGlobalPushSetting} instead of this constructor. * - * @param masterSecret API access secret of the appKey. - * @param appKey The KEY of one application on JPush. - * @param maxRetryTimes Client request retry times. - * @param proxy The proxy, if there is no proxy, should be null. - * @param conf The client configuration. Can use ClientConfig.getInstance() as default. + * @param masterSecret API access secret of the appKey. + * @param appKey The KEY of one application on JPush. + * @param maxRetryTimes Client request retry times. + * @param proxy The proxy, if there is no proxy, should be null. + * @param conf The client configuration. Can use ClientConfig.getInstance() as default. * @param apnsProduction Global APNs environment setting. It will override PushPayload Options. - * @param timeToLive Global time_to_live setting. It will override PushPayload Options. + * @param timeToLive Global time_to_live setting. It will override PushPayload Options. */ @Deprecated public JPushClient(String masterSecret, String appKey, int maxRetryTimes, HttpProxy proxy, ClientConfig conf, @@ -148,18 +151,18 @@ public JPushClient(String masterSecret, String appKey, int maxRetryTimes, HttpPr _deviceClient = new DeviceClient(masterSecret, appKey, proxy, conf); _scheduleClient = new ScheduleClient(masterSecret, appKey, proxy, conf); } - - /** - * Create a JPush Client with global settings. - * - * If you want different settings from default globally, this constructor is what you needed. - * This will be removed in the future. Please use ClientConfig{jiguang-common cn.jiguang.common.ClientConfig#setGlobalPushSetting} instead of this constructor. + + /** + * Create a JPush Client with global settings. + *

        + * If you want different settings from default globally, this constructor is what you needed. + * This will be removed in the future. Please use ClientConfig{jiguang-common cn.jiguang.common.ClientConfig#setGlobalPushSetting} instead of this constructor. * - * @param masterSecret API access secret of the appKey. - * @param appKey The KEY of one application on JPush. - * @param apnsProduction Global APNs environment setting. It will override PushPayload Options. - * @param timeToLive Global time_to_live setting. It will override PushPayload Options. - */ + * @param masterSecret API access secret of the appKey. + * @param appKey The KEY of one application on JPush. + * @param apnsProduction Global APNs environment setting. It will override PushPayload Options. + * @param timeToLive Global time_to_live setting. It will override PushPayload Options. + */ @Deprecated public JPushClient(String masterSecret, String appKey, boolean apnsProduction, long timeToLive) { ClientConfig conf = ClientConfig.getInstance(); @@ -179,28 +182,28 @@ public PushClient getPushClient() { /** * Send a push with PushPayload object. - * - * @param pushPayload payload object of a push. + * + * @param pushPayload payload object of a push. * @return PushResult The result object of a Push. Can be printed to a JSON. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ - public PushResult sendPush(PushPayload pushPayload) throws APIConnectionException, APIRequestException { - return _pushClient.sendPush(pushPayload); - } - - /** - * Send a push with JSON string. - * - * You can send a push JSON string directly with this method. - * - * Attention: globally settings cannot be affect this type of Push. - * - * @param payloadString payload of a push. + public PushResult sendPush(PushPayload pushPayload) throws APIConnectionException, APIRequestException { + return _pushClient.sendPush(pushPayload); + } + + /** + * Send a push with JSON string. + *

        + * You can send a push JSON string directly with this method. + *

        + * Attention: globally settings cannot be affect this type of Push. + * + * @param payloadString payload of a push. * @return PushResult. Can be printed to a JSON. - * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. - */ + * @throws APIConnectionException if a remote or network exception occurs. + * @throws APIRequestException if a request exception occurs. + */ public PushResult sendPush(String payloadString) throws APIConnectionException, APIRequestException { return _pushClient.sendPush(payloadString); } @@ -211,26 +214,26 @@ public PushResult sendPush(String payloadString) throws APIConnectionException, * @param pushPayload payload object of a push. * @return PushResult The result object of a Push. Can be printed to a JSON. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendFilePush(PushPayload pushPayload) throws APIConnectionException, APIRequestException { return _pushClient.sendFilePush(pushPayload); } - + /** * Validate a push action, but do NOT send it actually. - * + * * @param payload payload of a push. * @return PushResult. Can be printed to a JSON. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendPushValidate(PushPayload payload) throws APIConnectionException, APIRequestException { - return _pushClient.sendPushValidate(payload); + return _pushClient.sendPushValidate(payload); } public PushResult sendPushValidate(String payloadString) throws APIConnectionException, APIRequestException { - return _pushClient.sendPushValidate(payloadString); + return _pushClient.sendPushValidate(payloadString); } public BatchPushResult batchSendPushByRegId(List pushPayloadList) throws APIConnectionException, APIRequestException { @@ -243,35 +246,36 @@ public BatchPushResult batchSendPushByAlias(List pushPayloadList) t /** * Get cid list, the data form of cid is appKey-uuid. + * * @param count the count of cid list, from 1 to 1000. default is 1. - * @param type default is push, option: schedule + * @param type default is push, option: schedule * @return CIDResult, an array of cid * @throws APIConnectionException connect exception - * @throws APIRequestException request exception + * @throws APIRequestException request exception */ public CIDResult getCidList(int count, String type) throws APIConnectionException, APIRequestException { return _pushClient.getCidList(count, type); } - + // ------------------------------- Report API /** - * Get received report. - * + * Get received report. + * * @param msgIds 100 msgids to batch getting is supported. * @return ReceivedResult. Can be printed to JSON. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ReceivedsResult getReportReceiveds(String msgIds) throws APIConnectionException, APIRequestException { - return _reportClient.getReceiveds(msgIds); - } - + return _reportClient.getReceiveds(msgIds); + } + public UsersResult getReportUsers(TimeUnit timeUnit, String start, int duration) throws APIConnectionException, APIRequestException { return _reportClient.getUsers(timeUnit, start, duration); } - + public MessagesResult getReportMessages(String msgIds) throws APIConnectionException, APIRequestException { return _reportClient.getMessages(msgIds); } @@ -300,7 +304,7 @@ public GroupUsersResult getGroupReportUsers(TimeUnit timeUnit, String start, int APIRequestException { return _reportClient.getGroupUsers(timeUnit, start, duration); } - + // ------------------------------ Shortcuts - notification public PushResult sendNotificationAll(String alert) throws APIConnectionException, APIRequestException { @@ -313,18 +317,18 @@ public PushResult sendNotificationAll(String alert) throws APIConnectionExceptio * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. * * @param alert The notification content. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. * @return push result * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendNotificationAll(String alert, SMS sms) throws APIConnectionException, APIRequestException { PushPayload payload = PushPayload.alertAll(alert, sms); return _pushClient.sendPush(payload); } - public PushResult sendAndroidNotificationWithAlias(String title, String alert, - Map extras, String... alias) + public PushResult sendAndroidNotificationWithAlias(String title, String alert, + Map extras, String... alias) throws APIConnectionException, APIRequestException { PushPayload payload = PushPayload.newBuilder() .setPlatform(Platform.android()) @@ -338,14 +342,14 @@ public PushResult sendAndroidNotificationWithAlias(String title, String alert, * Send a notification to Android with alias. * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. * - * @param title The notification title. - * @param alert The notification content. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * @param title The notification title. + * @param alert The notification content. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. * @param extras The extra parameter. - * @param alias The users' alias. + * @param alias The users' alias. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendAndroidNotificationWithAlias(String title, String alert, SMS sms, Map extras, String... alias) @@ -359,8 +363,8 @@ public PushResult sendAndroidNotificationWithAlias(String title, String alert, S return _pushClient.sendPush(payload); } - public PushResult sendAndroidNotificationWithRegistrationID(String title, String alert, - Map extras, String... registrationID) + public PushResult sendAndroidNotificationWithRegistrationID(String title, String alert, + Map extras, String... registrationID) throws APIConnectionException, APIRequestException { PushPayload payload = PushPayload.newBuilder() .setPlatform(Platform.android()) @@ -374,14 +378,14 @@ public PushResult sendAndroidNotificationWithRegistrationID(String title, String * Send a notification to Android with RegistrationID. * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. * - * @param title The notification title. - * @param alert The notification content. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. - * @param extras The extra parameter. + * @param title The notification title. + * @param alert The notification content. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * @param extras The extra parameter. * @param registrationID The registration id generated by JPush. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendAndroidNotificationWithRegistrationID(String title, String alert, SMS sms, Map extras, String... registrationID) @@ -396,7 +400,7 @@ public PushResult sendAndroidNotificationWithRegistrationID(String title, String } public PushResult sendIosNotificationWithAlias(String alert, - Map extras, String... alias) + Map extras, String... alias) throws APIConnectionException, APIRequestException { PushPayload payload = PushPayload.newBuilder() .setPlatform(Platform.ios()) @@ -409,13 +413,14 @@ public PushResult sendIosNotificationWithAlias(String alert, /** * Send a notification to iOS with alias. * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. - * @param alert The notification content. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * + * @param alert The notification content. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. * @param extras The extra parameter. - * @param alias The users' alias. + * @param alias The users' alias. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendIosNotificationWithAlias(String alert, SMS sms, Map extras, String... alias) @@ -433,12 +438,12 @@ public PushResult sendIosNotificationWithAlias(String alert, SMS sms, * Send an iOS notification with alias. * If you want to send alert as a Json object, maybe this method is what you needed. * - * @param alert The wrapper of APNs alert. + * @param alert The wrapper of APNs alert. * @param extras The extra params. - * @param alias The alias list. + * @param alias The alias list. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendIosNotificationWithAlias(IosAlert alert, Map extras, String... alias) @@ -456,13 +461,13 @@ public PushResult sendIosNotificationWithAlias(IosAlert alert, * If you want to send alert as a Json object, maybe this method is what you needed. * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. * - * @param alert The wrapper of APNs alert. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * @param alert The wrapper of APNs alert. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. * @param extras The extra params. - * @param alias The alias list. + * @param alias The alias list. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendIosNotificationWithAlias(IosAlert alert, SMS sms, Map extras, String... alias) @@ -480,12 +485,12 @@ public PushResult sendIosNotificationWithAlias(IosAlert alert, SMS sms, * Send an iOS notification with alias. * If you want to send alert as a Json object, maybe this method is what you needed. * - * @param alert The JSON object of APNs alert. + * @param alert The JSON object of APNs alert. * @param extras The extra params. - * @param alias The alias list. + * @param alias The alias list. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendIosNotificationWithAlias(JsonObject alert, Map extras, String... alias) @@ -503,13 +508,13 @@ public PushResult sendIosNotificationWithAlias(JsonObject alert, * If you want to send alert as a Json object, maybe this method is what you needed. * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. * - * @param alert The JSON object of APNs alert. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * @param alert The JSON object of APNs alert. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. * @param extras The extra params. - * @param alias The alias list. + * @param alias The alias list. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendIosNotificationWithAlias(JsonObject alert, SMS sms, Map extras, String... alias) @@ -523,8 +528,8 @@ public PushResult sendIosNotificationWithAlias(JsonObject alert, SMS sms, return _pushClient.sendPush(payload); } - public PushResult sendIosNotificationWithRegistrationID(String alert, - Map extras, String... registrationID) + public PushResult sendIosNotificationWithRegistrationID(String alert, + Map extras, String... registrationID) throws APIConnectionException, APIRequestException { PushPayload payload = PushPayload.newBuilder() .setPlatform(Platform.ios()) @@ -538,13 +543,13 @@ public PushResult sendIosNotificationWithRegistrationID(String alert, * Send an iOS notification with registrationIds. * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. * - * @param alert The notification content. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. - * @param extras The extra params. + * @param alert The notification content. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * @param extras The extra params. * @param registrationID The alias list. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendIosNotificationWithRegistrationID(String alert, SMS sms, Map extras, String... registrationID) @@ -562,12 +567,12 @@ public PushResult sendIosNotificationWithRegistrationID(String alert, SMS sms, * Send an iOS notification with registrationIds. * If you want to send alert as a Json object, maybe this method is what you needed. * - * @param alert The wrapper of APNs alert. - * @param extras The extra params. + * @param alert The wrapper of APNs alert. + * @param extras The extra params. * @param registrationID The registration ids. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendIosNotificationWithRegistrationID(IosAlert alert, Map extras, String... registrationID) @@ -585,13 +590,13 @@ public PushResult sendIosNotificationWithRegistrationID(IosAlert alert, * If you want to send alert as a Json object, maybe this method is what you needed. * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. * - * @param alert The wrapper of APNs alert. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. - * @param extras The extra params. + * @param alert The wrapper of APNs alert. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * @param extras The extra params. * @param registrationID The registration ids. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendIosNotificationWithRegistrationID(IosAlert alert, SMS sms, Map extras, String... registrationID) @@ -609,12 +614,12 @@ public PushResult sendIosNotificationWithRegistrationID(IosAlert alert, SMS sms, * Send an iOS notification with registrationIds. * If you want to send alert as a Json object, maybe this method is what you needed. * - * @param alert The wrapper of APNs alert. - * @param extras The extra params. + * @param alert The wrapper of APNs alert. + * @param extras The extra params. * @param registrationID The registration ids. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendIosNotificationWithRegistrationID(JsonObject alert, Map extras, String... registrationID) @@ -632,13 +637,13 @@ public PushResult sendIosNotificationWithRegistrationID(JsonObject alert, * If you want to send alert as a Json object, maybe this method is what you needed. * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. * - * @param alert The JSON object of APNs alert. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. - * @param extras The extra params. + * @param alert The JSON object of APNs alert. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * @param extras The extra params. * @param registrationID The registration ids. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendIosNotificationWithRegistrationID(JsonObject alert, SMS sms, Map extras, String... registrationID) @@ -652,7 +657,7 @@ public PushResult sendIosNotificationWithRegistrationID(JsonObject alert, SMS sm return _pushClient.sendPush(payload); } - + // ---------------------- shortcuts - message public PushResult sendMessageAll(String msgContent) throws APIConnectionException, APIRequestException { @@ -665,17 +670,17 @@ public PushResult sendMessageAll(String msgContent) throws APIConnectionExceptio * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. * * @param msgContent The message content. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendMessageAll(String msgContent, SMS sms) throws APIConnectionException, APIRequestException { PushPayload payload = PushPayload.messageAll(msgContent, sms); return _pushClient.sendPush(payload); } - public PushResult sendAndroidMessageWithAlias(String title, String msgContent, String... alias) + public PushResult sendAndroidMessageWithAlias(String title, String msgContent, String... alias) throws APIConnectionException, APIRequestException { PushPayload payload = PushPayload.newBuilder() .setPlatform(Platform.android()) @@ -692,13 +697,13 @@ public PushResult sendAndroidMessageWithAlias(String title, String msgContent, S * Send an Android message with alias. * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. * - * @param title The message title. + * @param title The message title. * @param msgContent The message content. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. - * @param alias The alias list. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * @param alias The alias list. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendAndroidMessageWithAlias(String title, String msgContent, SMS sms, String... alias) throws APIConnectionException, APIRequestException { @@ -714,7 +719,7 @@ public PushResult sendAndroidMessageWithAlias(String title, String msgContent, S return _pushClient.sendPush(payload); } - public PushResult sendAndroidMessageWithRegistrationID(String title, String msgContent, String... registrationID) + public PushResult sendAndroidMessageWithRegistrationID(String title, String msgContent, String... registrationID) throws APIConnectionException, APIRequestException { PushPayload payload = PushPayload.newBuilder() .setPlatform(Platform.android()) @@ -731,13 +736,13 @@ public PushResult sendAndroidMessageWithRegistrationID(String title, String msgC * Send an Android message with registration id. * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. * - * @param title The message title. - * @param msgContent The message content. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * @param title The message title. + * @param msgContent The message content. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. * @param registrationID The registration id list. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendAndroidMessageWithRegistrationID(String title, String msgContent, SMS sms, String... registrationID) throws APIConnectionException, APIRequestException { @@ -753,7 +758,7 @@ public PushResult sendAndroidMessageWithRegistrationID(String title, String msgC return _pushClient.sendPush(payload); } - public PushResult sendIosMessageWithAlias(String title, String msgContent, String... alias) + public PushResult sendIosMessageWithAlias(String title, String msgContent, String... alias) throws APIConnectionException, APIRequestException { PushPayload payload = PushPayload.newBuilder() .setPlatform(Platform.ios()) @@ -770,13 +775,13 @@ public PushResult sendIosMessageWithAlias(String title, String msgContent, Strin * Send an iOS message with alias. * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. * - * @param title The message title. + * @param title The message title. * @param msgContent The message content. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. - * @param alias The alias list. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * @param alias The alias list. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendIosMessageWithAlias(String title, String msgContent, SMS sms, String... alias) throws APIConnectionException, APIRequestException { @@ -792,7 +797,7 @@ public PushResult sendIosMessageWithAlias(String title, String msgContent, SMS s return _pushClient.sendPush(payload); } - public PushResult sendIosMessageWithRegistrationID(String title, String msgContent, String... registrationID) + public PushResult sendIosMessageWithRegistrationID(String title, String msgContent, String... registrationID) throws APIConnectionException, APIRequestException { PushPayload payload = PushPayload.newBuilder() .setPlatform(Platform.ios()) @@ -809,13 +814,13 @@ public PushResult sendIosMessageWithRegistrationID(String title, String msgConte * Send an iOS message with registration id. * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. * - * @param title The message title. - * @param msgContent The message content. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * @param title The message title. + * @param msgContent The message content. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. * @param registrationID The registrationIds generated by JPush. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendIosMessageWithRegistrationID(String title, String msgContent, SMS sms, String... registrationID) throws APIConnectionException, APIRequestException { @@ -831,7 +836,7 @@ public PushResult sendIosMessageWithRegistrationID(String title, String msgConte return _pushClient.sendPush(payload); } - public PushResult sendMessageWithRegistrationID(String title, String msgContent, String... registrationID) + public PushResult sendMessageWithRegistrationID(String title, String msgContent, String... registrationID) throws APIConnectionException, APIRequestException { PushPayload payload = PushPayload.newBuilder() .setPlatform(Platform.all()) @@ -848,13 +853,13 @@ public PushResult sendMessageWithRegistrationID(String title, String msgContent, * Send a message with registrationIds. * If it doesn't received within the delay time,JPush will send a SMS to the corresponding users. * - * @param title The message title. - * @param msgContent The message content. - * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. + * @param title The message title. + * @param msgContent The message content. + * @param sms The SMS content and delay time. If null, sms doesn't work, no effect on Push feature. * @param registrationID The registrationIds generated by JPush. * @return push result. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public PushResult sendMessageWithRegistrationID(String title, String msgContent, SMS sms, String... registrationID) throws APIConnectionException, APIRequestException { @@ -872,7 +877,8 @@ public PushResult sendMessageWithRegistrationID(String title, String msgContent, /** * Delete a push by msgId. - * @param msgId The message id + * + * @param msgId The message id * @return delete result * @throws APIConnectionException if a remote or network exception occurs. * @throws APIRequestException if a request exception occurs @@ -881,85 +887,85 @@ public DefaultResult deletePush(String msgId) throws APIConnectionException, API return _pushClient.deletePush(msgId); } - + // ----------------------- Device - - public TagAliasResult getDeviceTagAlias(String registrationId) - throws APIConnectionException, APIRequestException { - return _deviceClient.getDeviceTagAlias(registrationId); + + public TagAliasResult getDeviceTagAlias(String registrationId) + throws APIConnectionException, APIRequestException { + return _deviceClient.getDeviceTagAlias(registrationId); } public DefaultResult updateDeviceTagAlias(String registrationId, boolean clearAlias, boolean clearTag) - throws APIConnectionException, APIRequestException { - return _deviceClient.updateDeviceTagAlias(registrationId, clearAlias, clearTag); + throws APIConnectionException, APIRequestException { + return _deviceClient.updateDeviceTagAlias(registrationId, clearAlias, clearTag); + } + + public DefaultResult updateDeviceTagAlias(String registrationId, String alias, + Set tagsToAdd, Set tagsToRemove) + throws APIConnectionException, APIRequestException { + return _deviceClient.updateDeviceTagAlias(registrationId, alias, tagsToAdd, tagsToRemove); + } + + public TagListResult getTagList() + throws APIConnectionException, APIRequestException { + return _deviceClient.getTagList(); + } + + public BooleanResult isDeviceInTag(String theTag, String registrationID) + throws APIConnectionException, APIRequestException { + return _deviceClient.isDeviceInTag(theTag, registrationID); + } + + public DefaultResult addRemoveDevicesFromTag(String theTag, + Set toAddUsers, Set toRemoveUsers) + throws APIConnectionException, APIRequestException { + return _deviceClient.addRemoveDevicesFromTag(theTag, toAddUsers, + toRemoveUsers); + } + + public DefaultResult deleteTag(String theTag, String platform) + throws APIConnectionException, APIRequestException { + return _deviceClient.deleteTag(theTag, platform); + } + + public AliasDeviceListResult getAliasDeviceList(String alias, + String platform) throws APIConnectionException, APIRequestException { + return _deviceClient.getAliasDeviceList(alias, platform); + } + + public DefaultResult deleteAlias(String alias, String platform) + throws APIConnectionException, APIRequestException { + return _deviceClient.deleteAlias(alias, platform); } - - public DefaultResult updateDeviceTagAlias(String registrationId, String alias, - Set tagsToAdd, Set tagsToRemove) + + public DefaultResult removeDevicesFromAlias(String alias, Set toRemoveDevice) throws APIConnectionException, APIRequestException { - return _deviceClient.updateDeviceTagAlias(registrationId, alias, tagsToAdd, tagsToRemove); - } - - public TagListResult getTagList() - throws APIConnectionException, APIRequestException { - return _deviceClient.getTagList(); - } - - public BooleanResult isDeviceInTag(String theTag, String registrationID) - throws APIConnectionException, APIRequestException { - return _deviceClient.isDeviceInTag(theTag, registrationID); - } - - public DefaultResult addRemoveDevicesFromTag(String theTag, - Set toAddUsers, Set toRemoveUsers) - throws APIConnectionException, APIRequestException { - return _deviceClient.addRemoveDevicesFromTag(theTag, toAddUsers, - toRemoveUsers); - } - - public DefaultResult deleteTag(String theTag, String platform) - throws APIConnectionException, APIRequestException { - return _deviceClient.deleteTag(theTag, platform); - } - - public AliasDeviceListResult getAliasDeviceList(String alias, - String platform) throws APIConnectionException, APIRequestException { - return _deviceClient.getAliasDeviceList(alias, platform); - } - - public DefaultResult deleteAlias(String alias, String platform) - throws APIConnectionException, APIRequestException { - return _deviceClient.deleteAlias(alias, platform); - } - - public DefaultResult removeDevicesFromAlias(String alias, Set toRemoveDevice) - throws APIConnectionException, APIRequestException { - return _deviceClient.removeDevicesFromAlias(alias, toRemoveDevice); - } + return _deviceClient.removeDevicesFromAlias(alias, toRemoveDevice); + } public Map getUserOnlineStatus(String... registrationIds) - throws APIConnectionException, APIRequestException - { + throws APIConnectionException, APIRequestException { return _deviceClient.getUserOnlineStatus(registrationIds); } public DefaultResult bindMobile(String registrationId, String mobile) - throws APIConnectionException, APIRequestException - { + throws APIConnectionException, APIRequestException { return _deviceClient.bindMobile(registrationId, mobile); } // ----------------------- Schedule + /** * Create a single schedule. - * @param name The schedule name. - * @param time The push time, format is 'yyyy-MM-dd HH:mm:ss' - * @param push The push payload. + * + * @param name The schedule name. + * @param time The push time, format is 'yyyy-MM-dd HH:mm:ss' + * @param push The push payload. * @param masterSecret master secret - * @param appKey app key + * @param appKey app key * @return The created scheduleResult instance. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleResult createSingleSchedule(String name, String time, PushPayload push, String masterSecret, String appKey) @@ -979,16 +985,17 @@ public ScheduleResult createSingleSchedule(String name, String time, PushPayload /** * Create a daily schedule push everyday. - * @param name The schedule name. - * @param start The schedule comes into effect date, format 'yyyy-MM-dd HH:mm:ss'. - * @param end The schedule expiration date, format 'yyyy-MM-dd HH:mm:ss'. - * @param time The push time, format 'HH:mm:ss' - * @param push The push payload. + * + * @param name The schedule name. + * @param start The schedule comes into effect date, format 'yyyy-MM-dd HH:mm:ss'. + * @param end The schedule expiration date, format 'yyyy-MM-dd HH:mm:ss'. + * @param time The push time, format 'HH:mm:ss' + * @param push The push payload. * @param masterSecret master secret - * @param appKey app key + * @param appKey app key * @return The created scheduleResult instance. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleResult createDailySchedule(String name, String start, String end, String time, PushPayload push, String masterSecret, String appKey) @@ -999,17 +1006,18 @@ public ScheduleResult createDailySchedule(String name, String start, String end, /** * Create a daily schedule push with a custom frequency. - * @param name The schedule name. - * @param start The schedule comes into effect date, format 'yyyy-MM-dd HH:mm:ss'. - * @param end The schedule expiration date, format 'yyyy-MM-dd HH:mm:ss'. - * @param time The push time, format 'HH:mm:ss' - * @param frequency The custom frequency. - * @param push The push payload. + * + * @param name The schedule name. + * @param start The schedule comes into effect date, format 'yyyy-MM-dd HH:mm:ss'. + * @param end The schedule expiration date, format 'yyyy-MM-dd HH:mm:ss'. + * @param time The push time, format 'HH:mm:ss' + * @param frequency The custom frequency. + * @param push The push payload. * @param masterSecret master secret - * @param appKey app key + * @param appKey app key * @return The created scheduleResult instance. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleResult createDailySchedule(String name, String start, String end, String time, int frequency, PushPayload push, String masterSecret, String appKey) @@ -1020,17 +1028,18 @@ public ScheduleResult createDailySchedule(String name, String start, String end, /** * Create a weekly schedule push every week at the appointed days. - * @param name The schedule name. - * @param start The schedule comes into effect date, format 'yyyy-MM-dd HH:mm:ss'. - * @param end The schedule expiration date, format 'yyyy-MM-dd HH:mm:ss'. - * @param time The push time, format 'HH:mm:ss' - * @param days The appointed days. - * @param push The push payload. + * + * @param name The schedule name. + * @param start The schedule comes into effect date, format 'yyyy-MM-dd HH:mm:ss'. + * @param end The schedule expiration date, format 'yyyy-MM-dd HH:mm:ss'. + * @param time The push time, format 'HH:mm:ss' + * @param days The appointed days. + * @param push The push payload. * @param masterSecret master secret - * @param appKey app key + * @param appKey app key * @return The created scheduleResult instance. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleResult createWeeklySchedule(String name, String start, String end, String time, Week[] days, PushPayload push, String masterSecret, String appKey) @@ -1038,7 +1047,7 @@ public ScheduleResult createWeeklySchedule(String name, String start, String end Preconditions.checkArgument(null != days && days.length> 0, "The days must not be empty."); String[] points = new String[days.length]; - for(int i = 0 ; i < days.length; i++) { + for (int i = 0; i < days.length; i++) { points[i] = days[i].name(); } return createPeriodicalSchedule(name, start, end, time, TimeUnit.WEEK, 1, points, push, @@ -1047,18 +1056,19 @@ public ScheduleResult createWeeklySchedule(String name, String start, String end /** * Create a weekly schedule push with a custom frequency at the appointed days. - * @param name The schedule name. - * @param start The schedule comes into effect date, format 'yyyy-MM-dd HH:mm:ss'. - * @param end The schedule expiration date, format 'yyyy-MM-dd HH:mm:ss'. - * @param time The push time, format 'HH:mm:ss'. - * @param frequency The custom frequency. - * @param days The appointed days. - * @param push The push payload. + * + * @param name The schedule name. + * @param start The schedule comes into effect date, format 'yyyy-MM-dd HH:mm:ss'. + * @param end The schedule expiration date, format 'yyyy-MM-dd HH:mm:ss'. + * @param time The push time, format 'HH:mm:ss'. + * @param frequency The custom frequency. + * @param days The appointed days. + * @param push The push payload. * @param masterSecret master secret - * @param appKey app key + * @param appKey app key * @return The created scheduleResult instance. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleResult createWeeklySchedule(String name, String start, String end, String time, int frequency, Week[] days, PushPayload push, String masterSecret, String appKey) @@ -1066,7 +1076,7 @@ public ScheduleResult createWeeklySchedule(String name, String start, String end Preconditions.checkArgument(null != days && days.length> 0, "The days must not be empty."); String[] points = new String[days.length]; - for(int i = 0 ; i < days.length; i++) { + for (int i = 0; i < days.length; i++) { points[i] = days[i].name(); } return createPeriodicalSchedule(name, start, end, time, TimeUnit.WEEK, frequency, points, push, masterSecret, appKey); @@ -1074,17 +1084,18 @@ public ScheduleResult createWeeklySchedule(String name, String start, String end /** * Create a monthly schedule push every month at the appointed days. - * @param name The schedule name. - * @param start The schedule comes into effect date, format 'yyyy-MM-dd HH:mm:ss'. - * @param end The schedule expiration date, format 'yyyy-MM-dd HH:mm:ss'. - * @param time The push time, format 'HH:mm:ss'. - * @param points The appointed days. - * @param push The push payload. + * + * @param name The schedule name. + * @param start The schedule comes into effect date, format 'yyyy-MM-dd HH:mm:ss'. + * @param end The schedule expiration date, format 'yyyy-MM-dd HH:mm:ss'. + * @param time The push time, format 'HH:mm:ss'. + * @param points The appointed days. + * @param push The push payload. * @param masterSecret master secret - * @param appKey app key + * @param appKey app key * @return The created scheduleResult instance. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleResult createMonthlySchedule(String name, String start, String end, String time, String[] points, PushPayload push, String masterSecret, String appKey) @@ -1095,18 +1106,19 @@ public ScheduleResult createMonthlySchedule(String name, String start, String en /** * Create a monthly schedule push with a custom frequency at the appointed days. - * @param name The schedule name. - * @param start The schedule comes into effect date, format 'yyyy-MM-dd HH:mm:ss'. - * @param end The schedule expiration date, format 'yyyy-MM-dd HH:mm:ss'. - * @param time The push time, format 'HH:mm:ss'. - * @param frequency The custom frequency. - * @param points The appointed days. - * @param push The push payload. + * + * @param name The schedule name. + * @param start The schedule comes into effect date, format 'yyyy-MM-dd HH:mm:ss'. + * @param end The schedule expiration date, format 'yyyy-MM-dd HH:mm:ss'. + * @param time The push time, format 'HH:mm:ss'. + * @param frequency The custom frequency. + * @param points The appointed days. + * @param push The push payload. * @param masterSecret master secret - * @param appKey app key + * @param appKey app key * @return The created scheduleResult instance. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleResult createMonthlySchedule(String name, String start, String end, String time, int frequency, String[] points, PushPayload push, String masterSecret, String appKey) @@ -1117,33 +1129,36 @@ public ScheduleResult createMonthlySchedule(String name, String start, String en /** * Get the schedule information by the schedule id. + * * @param scheduleId The schedule id. * @return The schedule information. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleResult getSchedule(String scheduleId) throws APIConnectionException, APIRequestException { - return _scheduleClient.getSchedule(scheduleId); + return _scheduleClient.getSchedule(scheduleId); } - + /** * Get the message id by the schedule id. + * * @param scheduleId The schedule id. * @return The message id list. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleMsgIdsResult getScheduleMsgIds(String scheduleId) throws APIConnectionException, APIRequestException { - return _scheduleClient.getScheduleMsgIds(scheduleId); + return _scheduleClient.getScheduleMsgIds(scheduleId); } /** * Get the schedule list size and the first page. + * * @return The schedule list size and the first page. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleListResult getScheduleList() throws APIConnectionException, APIRequestException { @@ -1152,10 +1167,11 @@ public ScheduleListResult getScheduleList() /** * Get the schedule list by the page. + * * @param page The page to search. * @return The schedule list of the appointed page. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleListResult getScheduleList(int page) throws APIConnectionException, APIRequestException { @@ -1164,11 +1180,12 @@ public ScheduleListResult getScheduleList(int page) /** * Update the schedule name + * * @param scheduleId The schedule id. - * @param name The new name. + * @param name The new name. * @return The schedule information after updated. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleResult updateScheduleName(String scheduleId, String name) throws APIConnectionException, APIRequestException { @@ -1181,10 +1198,11 @@ public ScheduleResult updateScheduleName(String scheduleId, String name) /** * Enable the schedule. + * * @param scheduleId The schedule id. * @return The schedule information after updated. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleResult enableSchedule(String scheduleId) throws APIConnectionException, APIRequestException { @@ -1197,10 +1215,11 @@ public ScheduleResult enableSchedule(String scheduleId) /** * Disable the schedule. + * * @param scheduleId The schedule id. * @return The schedule information after updated. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleResult disableSchedule(String scheduleId) throws APIConnectionException, APIRequestException { @@ -1212,11 +1231,12 @@ public ScheduleResult disableSchedule(String scheduleId) /** * Update the trigger of the schedule. + * * @param scheduleId The schedule id. - * @param trigger The new trigger. + * @param trigger The new trigger. * @return The schedule information after updated. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleResult updateScheduleTrigger(String scheduleId, TriggerPayload trigger) throws APIConnectionException, APIRequestException { @@ -1229,11 +1249,12 @@ public ScheduleResult updateScheduleTrigger(String scheduleId, TriggerPayload tr /** * Update the push content of the schedule. + * * @param scheduleId The schedule id. - * @param push The new push payload. + * @param push The new push payload. * @return The schedule information after updated. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleResult updateSchedulePush(String scheduleId, PushPayload push) throws APIConnectionException, APIRequestException { @@ -1246,11 +1267,12 @@ public ScheduleResult updateSchedulePush(String scheduleId, PushPayload push) /** * Update a schedule by the id. + * * @param scheduleId The schedule id to update. - * @param payload The new schedule payload. + * @param payload The new schedule payload. * @return The new schedule information. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public ScheduleResult updateSchedule(String scheduleId, SchedulePayload payload) throws APIConnectionException, APIRequestException { @@ -1259,9 +1281,10 @@ public ScheduleResult updateSchedule(String scheduleId, SchedulePayload payload) /** * Delete a schedule by id. + * * @param scheduleId The schedule id. * @throws APIConnectionException if a remote or network exception occurs. - * @throws APIRequestException if a request exception occurs. + * @throws APIRequestException if a request exception occurs. */ public void deleteSchedule(String scheduleId) throws APIConnectionException, APIRequestException { @@ -1274,7 +1297,7 @@ private ScheduleResult createPeriodicalSchedule(String name, String start, Strin throws APIConnectionException, APIRequestException { TriggerPayload trigger = TriggerPayload.newBuilder() .setPeriodTime(start, end, time) - .setTimeFrequency(timeUnit, frequency, point ) + .setTimeFrequency(timeUnit, frequency, point) .buildPeriodical(); SchedulePayload payload = SchedulePayload.newBuilder() .setName(name) @@ -1286,6 +1309,10 @@ private ScheduleResult createPeriodicalSchedule(String name, String start, Strin return _scheduleClient.createSchedule(payload, masterSecret, appKey); } + public PushResult sendLiveActivity(LiveActivity liveActivity) throws APIConnectionException, APIRequestException { + return _pushClient.sendLiveActivity(liveActivity); + } + public void close() { _pushClient.close(); } diff --git a/src/main/java/cn/jpush/api/push/PushClient.java b/src/main/java/cn/jpush/api/push/PushClient.java index 4a572d88..493d0818 100644 --- a/src/main/java/cn/jpush/api/push/PushClient.java +++ b/src/main/java/cn/jpush/api/push/PushClient.java @@ -10,6 +10,7 @@ import cn.jiguang.common.utils.sm2.SM2Util; import cn.jpush.api.push.model.*; import cn.jpush.api.push.model.audience.Audience; +import cn.jpush.api.push.model.live_activity.LiveActivity; import com.google.gson.*; import java.util.List; @@ -45,7 +46,8 @@ public class PushClient { // encrypt type, the default value is empty private String _encryptType; - public PushClient() {} + public PushClient() { + } /** * Create a Push Client. @@ -57,8 +59,8 @@ public PushClient(String masterSecret, String appKey) { this(masterSecret, appKey, null, ClientConfig.getInstance()); } - public PushClient(String masterSecret, String appKey,ClientConfig clientConfig){ - this(masterSecret,appKey,null,clientConfig); + public PushClient(String masterSecret, String appKey, ClientConfig clientConfig) { + this(masterSecret, appKey, null, clientConfig); } /** @@ -379,6 +381,12 @@ private void checkPushPayload(PushPayload pushPayload) { } } + + public PushResult sendLiveActivity(LiveActivity liveActivity) throws APIConnectionException, APIRequestException { + ResponseWrapper response = _httpClient.sendPost(_baseUrl + _pushPath, liveActivity.toJSON().toString()); + return BaseResult.fromResponse(response, PushResult.class); + } + } diff --git a/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java b/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java new file mode 100644 index 00000000..65ad98ad --- /dev/null +++ b/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java @@ -0,0 +1,194 @@ +package cn.jpush.api.push.model.live_activity; + +import cn.jpush.api.push.model.PushModel; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; + +public class LiveActivity implements PushModel { + + private final Boolean apnsProduction; + + private final String liveActivityId; + + private final String iOSEvent; + private final JsonObject iOSContentState; + private final String iOSAlertTitle; + private final String iOSAlertAlternateTitle; + private final String iOSAlertBody; + private final String iOSAlertAlternateBody; + private final String iOSAlertSound; + private final Integer iOSDismissalDate; + + public LiveActivity(Boolean apnsProduction, String liveActivityId, String iOSEvent, JsonObject iOSContentState, String iOSAlertTitle, String iOSAlertAlternateTitle, String iOSAlertBody, String iOSAlertAlternateBody, String iOSAlertSound, Integer iOSDismissalDate) { + this.apnsProduction = apnsProduction; + this.liveActivityId = liveActivityId; + this.iOSEvent = iOSEvent; + this.iOSContentState = iOSContentState; + this.iOSAlertTitle = iOSAlertTitle; + this.iOSAlertAlternateTitle = iOSAlertAlternateTitle; + this.iOSAlertBody = iOSAlertBody; + this.iOSAlertAlternateBody = iOSAlertAlternateBody; + this.iOSAlertSound = iOSAlertSound; + this.iOSDismissalDate = iOSDismissalDate; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public static class Builder { + private Boolean apnsProduction; + private String liveActivityId; + private String iOSEvent; + private JsonObject iOSContentState; + private String iOSAlertTitle; + private String iOSAlertAlternateTitle; + private String iOSAlertBody; + private String iOSAlertAlternateBody; + private String iOSAlertSound; + private Integer iOSDismissalDate; + + public Builder apnsProduction(Boolean apnsProduction) { + this.apnsProduction = apnsProduction; + return this; + } + + public Builder liveActivityId(String liveActivityId) { + this.liveActivityId = liveActivityId; + return this; + } + + public Builder iOSEvent(LiveActivityEvent iOSEvent) { + if (iOSEvent != null) { + this.iOSEvent = iOSEvent.getValue(); + } + return this; + } + + public Builder iOSContentState(String key, String value) { + if (this.iOSContentState == null) { + this.iOSContentState = new JsonObject(); + } + this.iOSContentState.addProperty(key, value); + return this; + } + + public Builder iOSContentState(String key, Number value) { + if (this.iOSContentState == null) { + this.iOSContentState = new JsonObject(); + } + this.iOSContentState.addProperty(key, value); + return this; + } + + public Builder iOSContentState(String key, Boolean value) { + if (this.iOSContentState == null) { + this.iOSContentState = new JsonObject(); + } + this.iOSContentState.addProperty(key, value); + return this; + } + + public Builder iOSAlertTitle(String iOSAlertTitle) { + this.iOSAlertTitle = iOSAlertTitle; + return this; + } + + public Builder iOSAlertAlternateTitle(String iOSAlertAlternateTitle) { + this.iOSAlertAlternateTitle = iOSAlertAlternateTitle; + return this; + } + + public Builder iOSAlertBody(String iOSAlertBody) { + this.iOSAlertBody = iOSAlertBody; + return this; + } + + public Builder iOSAlertAlternateBody(String iOSAlertAlternateBody) { + this.iOSAlertAlternateBody = iOSAlertAlternateBody; + return this; + } + + public Builder iOSAlertSound(String iOSAlertSound) { + this.iOSAlertSound = iOSAlertSound; + return this; + } + + public Builder iOSDismissalDate(Integer iOSDismissalDate) { + this.iOSDismissalDate = iOSDismissalDate; + return this; + } + + public LiveActivity build() { + return new LiveActivity(apnsProduction, liveActivityId, iOSEvent, iOSContentState, iOSAlertTitle, iOSAlertAlternateTitle, iOSAlertBody, iOSAlertAlternateBody, iOSAlertSound, iOSDismissalDate); + } + + } + + @Override + public JsonElement toJSON() { + JsonObject jsonObject = new JsonObject(); + + JsonArray platformJsonArray = new JsonArray(); + platformJsonArray.add(new JsonPrimitive("ios")); + + JsonObject audienceJsonObject = new JsonObject(); + if (liveActivityId != null) { + audienceJsonObject.addProperty("live_activity_id", liveActivityId); + } + + JsonObject optionsJsonObject = new JsonObject(); + if (apnsProduction != null) { + optionsJsonObject.addProperty("apns_production", apnsProduction); + } + if (iOSAlertTitle != null || iOSAlertAlternateTitle != null || iOSAlertBody != null || iOSAlertAlternateBody != null || iOSAlertSound != null) { + optionsJsonObject.addProperty("alternate_set", true); + } + + JsonObject liveActivityJsonObject = new JsonObject(); + JsonObject iOSJsonObject = new JsonObject(); + JsonObject alertJsonObject = new JsonObject(); + + if (iOSAlertTitle != null) { + alertJsonObject.addProperty("title", iOSAlertTitle); + } + if (iOSAlertAlternateTitle != null) { + alertJsonObject.addProperty("alternate_title", iOSAlertAlternateTitle); + } + if (iOSAlertBody != null) { + alertJsonObject.addProperty("body", iOSAlertBody); + } + if (iOSAlertAlternateBody != null) { + alertJsonObject.addProperty("alternate_body", iOSAlertAlternateBody); + } + if (iOSAlertSound != null) { + alertJsonObject.addProperty("sound", iOSAlertSound); + } + + if (iOSEvent != null) { + iOSJsonObject.addProperty("event", iOSEvent); + } + if (iOSContentState != null) { + iOSJsonObject.add("content-state", iOSContentState); + } + if (!alertJsonObject.entrySet().isEmpty()) { + iOSJsonObject.add("alert", alertJsonObject); + } + if (iOSDismissalDate != null) { + iOSJsonObject.addProperty("dismissal-date", iOSDismissalDate); + } + + if (!iOSJsonObject.entrySet().isEmpty()) { + liveActivityJsonObject.add("ios", iOSJsonObject); + } + + jsonObject.add("platform", platformJsonArray); + jsonObject.add("audience", audienceJsonObject); + jsonObject.add("live_activity", liveActivityJsonObject); + jsonObject.add("options", optionsJsonObject); + return jsonObject; + } + +} diff --git a/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivityEvent.java b/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivityEvent.java new file mode 100644 index 00000000..4f53e546 --- /dev/null +++ b/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivityEvent.java @@ -0,0 +1,24 @@ +package cn.jpush.api.push.model.live_activity; + +public enum LiveActivityEvent { + + UPDATE("update", "更新"), + END("end", "结束,dismissal-date为结束展示时间"); + + private String value; + private String describe; + + LiveActivityEvent(String value, String describe) { + this.value = value; + this.describe = describe; + } + + public String getValue() { + return this.value; + } + + public String getDescribe() { + return this.describe; + } + +} diff --git a/src/test/java/cn/jpush/api/push/model/LiveActivityTest.java b/src/test/java/cn/jpush/api/push/model/LiveActivityTest.java new file mode 100644 index 00000000..a25955ed --- /dev/null +++ b/src/test/java/cn/jpush/api/push/model/LiveActivityTest.java @@ -0,0 +1,38 @@ +package cn.jpush.api.push.model; + +import cn.jiguang.common.resp.APIConnectionException; +import cn.jiguang.common.resp.APIRequestException; +import cn.jpush.api.FastTests; +import cn.jpush.api.JPushClient; +import cn.jpush.api.push.PushResult; +import cn.jpush.api.push.model.live_activity.LiveActivity; +import cn.jpush.api.push.model.live_activity.LiveActivityEvent; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(FastTests.class) +public class LiveActivityTest { + + @Test + public void send() { + LiveActivity liveActivity = new LiveActivity.Builder() + .liveActivityId("LiveActivity-1") + .apnsProduction(false) + .iOSEvent(LiveActivityEvent.UPDATE) + .iOSContentState("eventStr", "你好") + .iOSContentState("eventTime", System.currentTimeMillis()) + .build(); + System.out.println("send liveActivity param:" + liveActivity.toJSON()); + + try { + JPushClient pushClient = new JPushClient("8d8623440ff329ff38597da3", "2785bc46145eaa91a00c0728"); + PushResult pushResult = pushClient.sendLiveActivity(liveActivity); + System.out.println("send liveActivity result:" + pushResult); + } catch (APIConnectionException e) { + throw new RuntimeException(e); + } catch (APIRequestException e) { + throw new RuntimeException(e); + } + } + +} From a415497d385f6e3af1b0b3dfcef2333e3cb2424e Mon Sep 17 00:00:00 2001 From: zhanq Date: 2023年5月29日 17:37:13 +0800 Subject: [PATCH 23/39] =?UTF-8?q?add=EF=BC=9A=E5=90=8C=E6=AD=A5=E5=AE=98?= =?UTF-8?q?=E7=BD=91=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../jpush/api/push/model/Notification3rd.java | 17 ++++- .../java/cn/jpush/api/push/model/Options.java | 67 ++++++++--------- .../model/live_activity/LiveActivity.java | 73 ++----------------- .../model/notification/IosNotification.java | 22 +++++- .../api/push/model/LiveActivityTest.java | 27 ++++++- 6 files changed, 100 insertions(+), 108 deletions(-) diff --git a/pom.xml b/pom.xml index 79beaa61..c0c6b7d7 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.6.8 + 3.6.9 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client diff --git a/src/main/java/cn/jpush/api/push/model/Notification3rd.java b/src/main/java/cn/jpush/api/push/model/Notification3rd.java index 7d0bd71b..8a6f622b 100644 --- a/src/main/java/cn/jpush/api/push/model/Notification3rd.java +++ b/src/main/java/cn/jpush/api/push/model/Notification3rd.java @@ -24,6 +24,7 @@ public class Notification3rd implements PushModel{ private static final String URI_ACTIVITY = "uri_activity"; private static final String URI_ACTION = "uri_action"; private static final String BADGE_ADD_NUM = "badge_add_num"; + private static final String BADGE_SET_NUM = "badge_set_num"; private static final String BADGE_CLASS = "badge_class"; private static final String SOUND = "sound"; private static final String EXTRAS = "extras"; @@ -35,6 +36,7 @@ public class Notification3rd implements PushModel{ private final String uri_activity; private final String uri_action; private final int badge_add_num; + private final int badge_set_num; private final String badge_class; private final String sound; private final Map extras; @@ -43,7 +45,7 @@ public class Notification3rd implements PushModel{ private final Map jsonExtras; private Notification3rd(String title, String content, String channel_id, - String uri_activity, String uri_action, int badge_add_num, + String uri_activity, String uri_action, int badge_add_num,int badge_set_num, String badge_class, String sound, Map extras, Map numberExtras, @@ -55,6 +57,7 @@ private Notification3rd(String title, String content, String channel_id, this.uri_activity = uri_activity; this.uri_action = uri_action; this.badge_add_num = badge_add_num; + this.badge_set_num = badge_set_num; this.badge_class = badge_class; this.sound = sound; this.extras = extras; @@ -97,6 +100,10 @@ public JsonElement toJSON() { json.addProperty(BADGE_ADD_NUM, badge_add_num); } + if (0 != badge_set_num) { + json.addProperty(BADGE_SET_NUM, badge_set_num); + } + if (null != badge_class) { json.addProperty(BADGE_CLASS, badge_class); } @@ -164,6 +171,7 @@ public static class Builder{ private String uri_activity; private String uri_action; private int badge_add_num; + private int badge_set_num; private String badge_class; private String sound; protected Map extrasBuilder; @@ -201,6 +209,11 @@ public Builder setBadgeAddNum(int badge_add_num) { return this; } + public Builder setBadgeSetNum(int badge_set_num) { + this.badge_set_num = badge_set_num; + return this; + } + public Builder setBadgeClass(String badge_class) { this.badge_class = badge_class; return this; @@ -263,7 +276,7 @@ public Builder addExtra(String key, JsonObject value) { public Notification3rd build() { Preconditions.checkArgument(content != null && content != "", "content should not be null or empty"); - return new Notification3rd(title, content, channel_id, uri_activity, uri_action, badge_add_num, + return new Notification3rd(title, content, channel_id, uri_activity, uri_action, badge_add_num, badge_set_num, badge_class, sound, extrasBuilder, numberExtrasBuilder, booleanExtrasBuilder, jsonExtrasBuilder); } } diff --git a/src/main/java/cn/jpush/api/push/model/Options.java b/src/main/java/cn/jpush/api/push/model/Options.java index f1208974..dfcae593 100644 --- a/src/main/java/cn/jpush/api/push/model/Options.java +++ b/src/main/java/cn/jpush/api/push/model/Options.java @@ -11,6 +11,22 @@ import java.util.Map; import java.util.Set; +/** + * 参考文档:https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push#options + * + *

        Options

        + *
        + *
          + *
        • sendno: 推送序号
        • + *
        • time_to_live: 离线消息保留时长 (秒)
        • + *
        • override_msg_id: 要覆盖的消息 ID
        • + *
        • apns_production: APNs 是否生产环境
        • + *
        • apns_collapse_id: 更新 iOS 通知的标识符
        • + *
        • big_push_duration: 定速推送时长 (分钟)
        • + *
        • third_party_channel: 推送请求下发通道
        • + *
        • classification: 消息类型分类,极光不对指定的消息类型进行判断或校准,会以开发者自行指定的消息类型适配 Android 厂商通道。不填默认为 0
        • + *
        + */ public class Options implements PushModel { private static final String SENDNO = "sendno"; @@ -20,6 +36,7 @@ public class Options implements PushModel { private static final String BIG_PUSH_DURATION = "big_push_duration"; private static final String APNS_COLLAPSE_ID = "apns_collapse_id"; private static final String THIRD_PARTH_CHANNEl = "third_party_channel"; + private static final String CLASSIFICATION = "classification"; private static final long NONE_TIME_TO_LIVE = -1; @@ -30,38 +47,12 @@ public class Options implements PushModel { // minutes private int bigPushDuration; private String apnsCollapseId; - private final Map customData; - - + private int classification; /** - * { - * "third_party_channel":{ - * "xiaomi":{ - * "distribution":"ospush", - * "channel_id":"*******" - * }, - * "huawei":{ - * "distribution":"jpush" - * }, - * "meizu":{ - * "distribution":"jpush" - * }, - * "fcm":{ - * "distribution":"ospush" - * }, - * "oppo":{ - * "distribution":"ospush", - * "channel_id":"*******" - * }, - * "vivo":{ - * "distribution":"ospush", - * "classification":0 // 2020/06 新增,和vivo官方字段含义一致 0 代表运营消息,1 代表系统消息,不填vivo官方默认为0 - * // 使用此字段时,需使用setThirdPartyChannelV2方法,因为此值只能为整数形式 - * } - * } - * } + * 参考:https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push#third_party_channel-%E8%AF%B4%E6%98%8E */ private Map thirdPartyChannel; + private final Map customData; private Options(int sendno, long overrideMsgId, @@ -69,6 +60,7 @@ private Options(int sendno, boolean apnsProduction, int bigPushDuration, String apnsCollapseId, + int classification, Map thirdPartyChannel, Map customData) { this.sendno = sendno; @@ -77,6 +69,7 @@ private Options(int sendno, this.apnsProduction = apnsProduction; this.bigPushDuration = bigPushDuration; this.apnsCollapseId = apnsCollapseId; + this.classification = classification; this.thirdPartyChannel = thirdPartyChannel; this.customData = customData; } @@ -132,6 +125,8 @@ public JsonElement toJSON() { json.add(APNS_COLLAPSE_ID, new JsonPrimitive(apnsCollapseId)); } + json.add(CLASSIFICATION, new JsonPrimitive(classification)); + if (null != thirdPartyChannel && thirdPartyChannel.size()> 0) { JsonObject partyChannel = new JsonObject(); for (Map.Entry entry : thirdPartyChannel.entrySet()) { @@ -158,6 +153,7 @@ public static class Builder { private boolean apnsProduction = false; private int bigPushDuration = 0; private String apnsCollapseId; + private int classification; private Map thirdPartyChannel; private Map customData; @@ -191,6 +187,11 @@ public Builder setBigPushDuration(int bigPushDuration) { return this; } + public Builder setClassification(int classification) { + this.classification = classification; + return this; + } + @Deprecated public Map> getThirdPartyChannel() { if (null != thirdPartyChannel) { @@ -248,7 +249,7 @@ public Builder addCustom(Map extras) { } public Builder addCustom(String key, Number value) { - Preconditions.checkArgument(! (null == key), "Key should not be null."); + Preconditions.checkArgument(!(null == key), "Key should not be null."); if (customData == null) { customData = new LinkedHashMap(); } @@ -257,7 +258,7 @@ public Builder addCustom(String key, Number value) { } public Builder addCustom(String key, String value) { - Preconditions.checkArgument(! (null == key), "Key should not be null."); + Preconditions.checkArgument(!(null == key), "Key should not be null."); if (customData == null) { customData = new LinkedHashMap(); } @@ -266,7 +267,7 @@ public Builder addCustom(String key, String value) { } public Builder addCustom(String key, Boolean value) { - Preconditions.checkArgument(! (null == key), "Key should not be null."); + Preconditions.checkArgument(!(null == key), "Key should not be null."); if (customData == null) { customData = new LinkedHashMap(); } @@ -284,7 +285,7 @@ public Options build() { sendno = ServiceHelper.generateSendno(); } - return new Options(sendno, overrideMsgId, timeToLive, apnsProduction, bigPushDuration, apnsCollapseId, thirdPartyChannel, customData); + return new Options(sendno, overrideMsgId, timeToLive, apnsProduction, bigPushDuration, apnsCollapseId, classification, thirdPartyChannel, customData); } } diff --git a/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java b/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java index 65ad98ad..eefc1b80 100644 --- a/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java +++ b/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java @@ -14,23 +14,13 @@ public class LiveActivity implements PushModel { private final String iOSEvent; private final JsonObject iOSContentState; - private final String iOSAlertTitle; - private final String iOSAlertAlternateTitle; - private final String iOSAlertBody; - private final String iOSAlertAlternateBody; - private final String iOSAlertSound; - private final Integer iOSDismissalDate; - - public LiveActivity(Boolean apnsProduction, String liveActivityId, String iOSEvent, JsonObject iOSContentState, String iOSAlertTitle, String iOSAlertAlternateTitle, String iOSAlertBody, String iOSAlertAlternateBody, String iOSAlertSound, Integer iOSDismissalDate) { + private final Long iOSDismissalDate; + + public LiveActivity(Boolean apnsProduction, String liveActivityId, String iOSEvent, JsonObject iOSContentState, Long iOSDismissalDate) { this.apnsProduction = apnsProduction; this.liveActivityId = liveActivityId; this.iOSEvent = iOSEvent; this.iOSContentState = iOSContentState; - this.iOSAlertTitle = iOSAlertTitle; - this.iOSAlertAlternateTitle = iOSAlertAlternateTitle; - this.iOSAlertBody = iOSAlertBody; - this.iOSAlertAlternateBody = iOSAlertAlternateBody; - this.iOSAlertSound = iOSAlertSound; this.iOSDismissalDate = iOSDismissalDate; } @@ -43,12 +33,7 @@ public static class Builder { private String liveActivityId; private String iOSEvent; private JsonObject iOSContentState; - private String iOSAlertTitle; - private String iOSAlertAlternateTitle; - private String iOSAlertBody; - private String iOSAlertAlternateBody; - private String iOSAlertSound; - private Integer iOSDismissalDate; + private Long iOSDismissalDate; public Builder apnsProduction(Boolean apnsProduction) { this.apnsProduction = apnsProduction; @@ -91,38 +76,13 @@ public Builder iOSContentState(String key, Boolean value) { return this; } - public Builder iOSAlertTitle(String iOSAlertTitle) { - this.iOSAlertTitle = iOSAlertTitle; - return this; - } - - public Builder iOSAlertAlternateTitle(String iOSAlertAlternateTitle) { - this.iOSAlertAlternateTitle = iOSAlertAlternateTitle; - return this; - } - - public Builder iOSAlertBody(String iOSAlertBody) { - this.iOSAlertBody = iOSAlertBody; - return this; - } - - public Builder iOSAlertAlternateBody(String iOSAlertAlternateBody) { - this.iOSAlertAlternateBody = iOSAlertAlternateBody; - return this; - } - - public Builder iOSAlertSound(String iOSAlertSound) { - this.iOSAlertSound = iOSAlertSound; - return this; - } - - public Builder iOSDismissalDate(Integer iOSDismissalDate) { + public Builder iOSDismissalDate(Long iOSDismissalDate) { this.iOSDismissalDate = iOSDismissalDate; return this; } public LiveActivity build() { - return new LiveActivity(apnsProduction, liveActivityId, iOSEvent, iOSContentState, iOSAlertTitle, iOSAlertAlternateTitle, iOSAlertBody, iOSAlertAlternateBody, iOSAlertSound, iOSDismissalDate); + return new LiveActivity(apnsProduction, liveActivityId, iOSEvent, iOSContentState, iOSDismissalDate); } } @@ -143,30 +103,11 @@ public JsonElement toJSON() { if (apnsProduction != null) { optionsJsonObject.addProperty("apns_production", apnsProduction); } - if (iOSAlertTitle != null || iOSAlertAlternateTitle != null || iOSAlertBody != null || iOSAlertAlternateBody != null || iOSAlertSound != null) { - optionsJsonObject.addProperty("alternate_set", true); - } JsonObject liveActivityJsonObject = new JsonObject(); JsonObject iOSJsonObject = new JsonObject(); JsonObject alertJsonObject = new JsonObject(); - if (iOSAlertTitle != null) { - alertJsonObject.addProperty("title", iOSAlertTitle); - } - if (iOSAlertAlternateTitle != null) { - alertJsonObject.addProperty("alternate_title", iOSAlertAlternateTitle); - } - if (iOSAlertBody != null) { - alertJsonObject.addProperty("body", iOSAlertBody); - } - if (iOSAlertAlternateBody != null) { - alertJsonObject.addProperty("alternate_body", iOSAlertAlternateBody); - } - if (iOSAlertSound != null) { - alertJsonObject.addProperty("sound", iOSAlertSound); - } - if (iOSEvent != null) { iOSJsonObject.addProperty("event", iOSEvent); } @@ -176,7 +117,7 @@ public JsonElement toJSON() { if (!alertJsonObject.entrySet().isEmpty()) { iOSJsonObject.add("alert", alertJsonObject); } - if (iOSDismissalDate != null) { + if (!alertJsonObject.entrySet().isEmpty()) { iOSJsonObject.addProperty("dismissal-date", iOSDismissalDate); } diff --git a/src/main/java/cn/jpush/api/push/model/notification/IosNotification.java b/src/main/java/cn/jpush/api/push/model/notification/IosNotification.java index 4e7cf7ca..c8c844af 100644 --- a/src/main/java/cn/jpush/api/push/model/notification/IosNotification.java +++ b/src/main/java/cn/jpush/api/push/model/notification/IosNotification.java @@ -14,13 +14,15 @@ * 支持 APNs 默认的几个参数: *
          *
        • alert: 继承自父类 PlatformNotification 的 alert 属性;本类设置则覆盖。
        • - *
        • badge: 支持 setBadge(int) 方法来设置;支持 incrBadge(int) 方法来增加。
        • *
        • sound: 支持 setSound(string) 方法来设置声音文件。或者 setSound(JSON object) 对应官方payload结构
        • + *
        • badge: 支持 setBadge(int) 方法来设置;支持 incrBadge(int) 方法来增加。
        • *
        • content-available: 用来支持后台推送。如果该值赋值为 1,表示开启后台推送。
        • *
        • mutable-content: 通知扩展
        • *
        • category: IOS 8 才支持。设置 APNs payload 中的 "category" 字段值
        • *
        • mutable-content: 通知扩展
        • *
        • extras: JSON object. 支持更多的自定义字段信息。
        • + *
        • thread-id: string. ios 的远程通知通过该属性来对通知进行分组,同一个 thread-id 的通知归为一组。
        • + *
        • interruption-level: string. ios 15 的通知级别,取值只能是 active,critical,passive,time-sensitive 中的一个,详情参考:UNNotificationInterruptionLevel。
        • *
        *
        * 需要特别留意的是,JPush SDK 会对以下几个值有特别的默认设置考虑: @@ -41,7 +43,8 @@ public class IosNotification extends PlatformNotification { private static final String MUTABLE_CONTENT = "mutable-content"; private static final String CATEGORY = "category"; private static final String THREAD_ID = "thread-id"; - + private static final String INTERRUPTION_LEVEL = "interruption-level"; + private static final String ALERT_VALID_BADGE = "Badge number should be 0~99999, " + "and can be prefixed with + to add, - to minus"; @@ -54,10 +57,11 @@ public class IosNotification extends PlatformNotification { private final String category; private final boolean mutableContent; private final String threadId; + private final String interruptionLevel; private IosNotification(Object alert, Object sound, String badge, boolean contentAvailable, boolean soundDisabled, boolean badgeDisabled, - String category, boolean mutableContent,String threadId, + String category, boolean mutableContent,String threadId,String interruptionLevel, Map extras, Map numberExtras, Map booleanExtras, @@ -73,6 +77,7 @@ private IosNotification(Object alert, Object sound, String badge, this.category = category; this.mutableContent = mutableContent; this.threadId = threadId; + this.interruptionLevel = interruptionLevel; } public static Builder newBuilder() { @@ -124,6 +129,9 @@ public JsonElement toJSON() { if (null != threadId) { json.add(THREAD_ID, new JsonPrimitive(threadId)); } + if (null != interruptionLevel) { + json.add(INTERRUPTION_LEVEL, new JsonPrimitive(interruptionLevel)); + } return json; } @@ -138,6 +146,7 @@ public static class Builder extends PlatformNotification.Builder Date: Thu, 1 Jun 2023 10:27:52 +0800 Subject: [PATCH 24/39] =?UTF-8?q?update=EF=BC=9A3.7.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c0c6b7d7..1ba4fb00 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.6.9 + 3.7.0 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client From 14e80b2d3fc9c68be7fba0fa7f0b0b342f6e05e1 Mon Sep 17 00:00:00 2001 From: zhanq Date: 2023年6月13日 19:59:05 +0800 Subject: [PATCH 25/39] =?UTF-8?q?add=EF=BC=9A=E5=90=8C=E6=AD=A5=E5=AE=98?= =?UTF-8?q?=E7=BD=91=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../model/live_activity/LiveActivity.java | 89 ++++++++++++++----- .../api/push/model/LiveActivityTest.java | 7 ++ 3 files changed, 75 insertions(+), 23 deletions(-) diff --git a/pom.xml b/pom.xml index 1ba4fb00..7dc3ce9c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.7.0 + 3.7.1 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client diff --git a/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java b/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java index eefc1b80..2a8fa091 100644 --- a/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java +++ b/src/main/java/cn/jpush/api/push/model/live_activity/LiveActivity.java @@ -1,10 +1,7 @@ package cn.jpush.api.push.model.live_activity; import cn.jpush.api.push.model.PushModel; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; +import com.google.gson.*; public class LiveActivity implements PushModel { @@ -15,13 +12,15 @@ public class LiveActivity implements PushModel { private final String iOSEvent; private final JsonObject iOSContentState; private final Long iOSDismissalDate; + private final JsonObject iOSAlert; - public LiveActivity(Boolean apnsProduction, String liveActivityId, String iOSEvent, JsonObject iOSContentState, Long iOSDismissalDate) { + public LiveActivity(Boolean apnsProduction, String liveActivityId, String iOSEvent, JsonObject iOSContentState, Long iOSDismissalDate, JsonObject iOSAlert) { this.apnsProduction = apnsProduction; this.liveActivityId = liveActivityId; this.iOSEvent = iOSEvent; this.iOSContentState = iOSContentState; this.iOSDismissalDate = iOSDismissalDate; + this.iOSAlert = iOSAlert; } public static Builder newBuilder() { @@ -34,6 +33,7 @@ public static class Builder { private String iOSEvent; private JsonObject iOSContentState; private Long iOSDismissalDate; + private JsonObject iOSAlert; public Builder apnsProduction(Boolean apnsProduction) { this.apnsProduction = apnsProduction; @@ -81,15 +81,55 @@ public Builder iOSDismissalDate(Long iOSDismissalDate) { return this; } + public Builder iOSAlertTitle(String iosAlertTitle) { + if (this.iOSAlert == null) { + this.iOSAlert = new JsonObject(); + } + this.iOSAlert.addProperty("title", iosAlertTitle); + return this; + } + + public Builder iOSAlertAlternateTitle(String iosAlertAlternateTitle) { + if (this.iOSAlert == null) { + this.iOSAlert = new JsonObject(); + } + this.iOSAlert.addProperty("alternate_title", iosAlertAlternateTitle); + return this; + } + + public Builder iOSAlertBody(String iosAlertBody) { + if (this.iOSAlert == null) { + this.iOSAlert = new JsonObject(); + } + this.iOSAlert.addProperty("body", iosAlertBody); + return this; + } + + public Builder iOSAlertAlternateBody(String iosAlertAlternateBody) { + if (this.iOSAlert == null) { + this.iOSAlert = new JsonObject(); + } + this.iOSAlert.addProperty("alternate_body", iosAlertAlternateBody); + return this; + } + + public Builder iOSAlertSound(String iosAlertSound) { + if (this.iOSAlert == null) { + this.iOSAlert = new JsonObject(); + } + this.iOSAlert.addProperty("sound", iosAlertSound); + return this; + } + public LiveActivity build() { - return new LiveActivity(apnsProduction, liveActivityId, iOSEvent, iOSContentState, iOSDismissalDate); + return new LiveActivity(apnsProduction, liveActivityId, iOSEvent, iOSContentState, iOSDismissalDate, iOSAlert); } } @Override public JsonElement toJSON() { - JsonObject jsonObject = new JsonObject(); + JsonObject pushJsonObject = new JsonObject(); JsonArray platformJsonArray = new JsonArray(); platformJsonArray.add(new JsonPrimitive("ios")); @@ -99,37 +139,42 @@ public JsonElement toJSON() { audienceJsonObject.addProperty("live_activity_id", liveActivityId); } - JsonObject optionsJsonObject = new JsonObject(); - if (apnsProduction != null) { - optionsJsonObject.addProperty("apns_production", apnsProduction); - } - JsonObject liveActivityJsonObject = new JsonObject(); JsonObject iOSJsonObject = new JsonObject(); - JsonObject alertJsonObject = new JsonObject(); if (iOSEvent != null) { iOSJsonObject.addProperty("event", iOSEvent); } + if (iOSContentState != null) { iOSJsonObject.add("content-state", iOSContentState); } - if (!alertJsonObject.entrySet().isEmpty()) { - iOSJsonObject.add("alert", alertJsonObject); - } - if (!alertJsonObject.entrySet().isEmpty()) { + + if (iOSDismissalDate != null) { iOSJsonObject.addProperty("dismissal-date", iOSDismissalDate); } + if (iOSAlert != null) { + iOSJsonObject.add("alert", iOSAlert); + } + if (!iOSJsonObject.entrySet().isEmpty()) { liveActivityJsonObject.add("ios", iOSJsonObject); } - jsonObject.add("platform", platformJsonArray); - jsonObject.add("audience", audienceJsonObject); - jsonObject.add("live_activity", liveActivityJsonObject); - jsonObject.add("options", optionsJsonObject); - return jsonObject; + JsonObject optionsJsonObject = new JsonObject(); + if (apnsProduction != null) { + optionsJsonObject.addProperty("apns_production", apnsProduction); + } + if (iOSAlert != null) { + optionsJsonObject.addProperty("alternate_set", true); + } + + pushJsonObject.add("platform", platformJsonArray); + pushJsonObject.add("audience", audienceJsonObject); + pushJsonObject.add("live_activity", liveActivityJsonObject); + pushJsonObject.add("options", optionsJsonObject); + return pushJsonObject; } } diff --git a/src/test/java/cn/jpush/api/push/model/LiveActivityTest.java b/src/test/java/cn/jpush/api/push/model/LiveActivityTest.java index 5dfed5b4..b8d1a797 100644 --- a/src/test/java/cn/jpush/api/push/model/LiveActivityTest.java +++ b/src/test/java/cn/jpush/api/push/model/LiveActivityTest.java @@ -21,6 +21,13 @@ public void update() { .iOSEvent(LiveActivityEvent.UPDATE) .iOSContentState("eventStr", "更新") .iOSContentState("eventTime", System.currentTimeMillis()) + .iOSContentState("eventBool", true) + // 需要联系商务开通 alternate_set 才能使用 + // .iOSAlertTitle("alertTitle") + // .iOSAlertAlternateTitle("alertAlternateTitle") + // .iOSAlertBody("alertBody") + // .iOSAlertAlternateBody("alertAlternateBody") + // .iOSAlertSound("alertSound") .build(); System.out.println("send liveActivity param:" + liveActivity.toJSON()); From 7b1c3bffd3f8d532f66bbda491b6cdafe1efe844 Mon Sep 17 00:00:00 2001 From: wicked-tc130 Date: 2023年8月26日 18:52:19 +0800 Subject: [PATCH 26/39] =?UTF-8?q?fix=EF=BC=9AscheduleClient=E5=86=85?= =?UTF-8?q?=E6=9E=84=E5=BB=BApushClient=E6=97=B6=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E4=BC=A0=E5=8F=82proxy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cn/jpush/api/schedule/ScheduleClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cn/jpush/api/schedule/ScheduleClient.java b/src/main/java/cn/jpush/api/schedule/ScheduleClient.java index 9d88cb57..d5efa7fc 100644 --- a/src/main/java/cn/jpush/api/schedule/ScheduleClient.java +++ b/src/main/java/cn/jpush/api/schedule/ScheduleClient.java @@ -84,7 +84,7 @@ public ScheduleClient(String masterSecret, String appKey, HttpProxy proxy, Clien apnsProduction = (Integer) conf.get(ClientConfig.APNS_PRODUCTION); timeToLive = (Long) conf.get(ClientConfig.TIME_TO_LIVE); //createSchedule接口需要用到这个类 - pushClient = new PushClient(masterSecret, appKey, conf); + pushClient = new PushClient(masterSecret, appKey, proxy, conf); String authCode = ServiceHelper.getBasicAuthorization(appKey, masterSecret); this._httpClient = new NativeHttpClient(authCode, proxy, conf); From 05397cbd130fbaa8f0ba5c81ab4284359c84eb83 Mon Sep 17 00:00:00 2001 From: wicked-tc130 Date: 2023年8月26日 19:02:56 +0800 Subject: [PATCH 27/39] update version to 3.7.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7dc3ce9c..f873ca1b 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.7.1 + 3.7.3 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client From 1a84baa7011770bee8850ac509b131c72154b4b1 Mon Sep 17 00:00:00 2001 From: wangym Date: 2024年1月25日 14:12:45 +0800 Subject: [PATCH 28/39] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 40c55d37..16c69a0f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +# 温馨提示 +极光已推出新版本的 SDK 供广大用户使用,当前版本后续将不推荐使用,请移步仓库 [jiguang-sdk-java-v5](https://github.com/jpush/jiguang-sdk-java-v5) 了解更多。 + + [![GitHub version](https://badge.fury.io/gh/jpush%2Fjpush-api-java-client.svg)](http://badge.fury.io/gh/jpush%2Fjpush-api-java-client) # JPush API Java Library From 4e15661ad454c434008af8e7072e1d9d30855099 Mon Sep 17 00:00:00 2001 From: wicked-tc130 Date: 2024年1月25日 17:02:34 +0800 Subject: [PATCH 29/39] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 16c69a0f..1c99bf90 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # 温馨提示 -极光已推出新版本的 SDK 供广大用户使用,当前版本后续将不推荐使用,请移步仓库 [jiguang-sdk-java-v5](https://github.com/jpush/jiguang-sdk-java-v5) 了解更多。 +极光已推出新版本的 SDK 供广大用户使用,当前版本后续将不推荐使用,请移步仓库 [jiguang-sdk-java](https://github.com/jpush/jiguang-sdk-java) 了解更多。 [![GitHub version](https://badge.fury.io/gh/jpush%2Fjpush-api-java-client.svg)](http://badge.fury.io/gh/jpush%2Fjpush-api-java-client) From 9023df639cdd2f7a6787e88258eeb4b5d0c38b98 Mon Sep 17 00:00:00 2001 From: zhanq Date: Thu, 1 Feb 2024 10:02:47 +0800 Subject: [PATCH 30/39] update jiguang-common version to 1.2.3. --- pom.xml | 2 +- .../java/cn/jpush/api/files/FileClient2.java | 92 +++++++++++++++++++ .../cn/jpush/api/files/FileClientTest.java | 6 ++ 3 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 src/test/java/cn/jpush/api/files/FileClient2.java diff --git a/pom.xml b/pom.xml index f873ca1b..b4697d98 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ cn.jpush.api jiguang-common - 1.2.2 + 1.2.3 org.apache.httpcomponents diff --git a/src/test/java/cn/jpush/api/files/FileClient2.java b/src/test/java/cn/jpush/api/files/FileClient2.java new file mode 100644 index 00000000..b005aa1b --- /dev/null +++ b/src/test/java/cn/jpush/api/files/FileClient2.java @@ -0,0 +1,92 @@ +package cn.jpush.api.files; + +import cn.jiguang.common.ClientConfig; +import cn.jiguang.common.ServiceHelper; +import cn.jiguang.common.connection.HttpProxy; +import cn.jiguang.common.connection.IHttpClient; +import cn.jiguang.common.connection.NativeHttpClient; +import cn.jiguang.common.resp.APIConnectionException; +import cn.jiguang.common.resp.APIRequestException; +import cn.jiguang.common.resp.ResponseWrapper; +import cn.jiguang.common.utils.Preconditions; +import cn.jiguang.common.utils.StringUtils; +import cn.jpush.api.file.model.FileModel; +import cn.jpush.api.file.model.FileModelPage; +import cn.jpush.api.file.model.FileType; +import cn.jpush.api.file.model.FileUploadResult; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author daixuan + * @version 2020年2月23日 19:38 + */ +public class FileClient2 { + + protected static final Logger LOG = LoggerFactory.getLogger(FileClient2.class); + + private IHttpClient _httpClient; + private String _baseUrl; + private String _filesPath; + private Gson _gson = new Gson(); + + public FileClient2(String masterSecret, String appKey) { + this(masterSecret, appKey, null, ClientConfig.getInstance()); + } + + public FileClient2(String masterSecret, String appKey, HttpProxy proxy, ClientConfig conf) { + _baseUrl = (String) conf.get(ClientConfig.PUSH_HOST_NAME); + _filesPath = (String) conf.get(ClientConfig.V3_FILES_PATH); + String authCode = ServiceHelper.getBasicAuthorization(appKey, masterSecret); + this._httpClient = new NativeHttpClient(authCode, proxy, conf); + } + + public String uploadFile(FileType type, String filename, Integer ttl) + throws APIConnectionException, APIRequestException { + Preconditions.checkArgument(type != null, "type should not be null"); + Preconditions.checkArgument(StringUtils.isNotEmpty(filename), "filename should not be null"); + Preconditions.checkArgument(ttl>= 1 && ttl <= 720,"TTL is not in the range of 1 to 720"); + NativeHttpClient client = (NativeHttpClient) _httpClient; + String typeStr = type.value(); + String url = _baseUrl + _filesPath + "/" + typeStr; + Map fileMap = new HashMap(); + fileMap.put("filename", filename); + Map textMap = new HashMap(); + textMap.put("ttl",String.valueOf(ttl)); + String response = client.formUploadByPost(url, textMap, fileMap, null); + LOG.info("uploadFile:{}", response); + return response; + } + + public String uploadFile(FileType type, String filename) throws APIConnectionException, APIRequestException { + return uploadFile(type,filename,720); + } + + public String queryEffectFiles() throws APIConnectionException, APIRequestException { + String url = _baseUrl + _filesPath + "/"; + ResponseWrapper response = _httpClient.sendGet(url); + LOG.info("queryEffFiles:{}", response); + return response.responseContent; + } + + public String queryFile(String fileId) throws APIConnectionException, APIRequestException { + Preconditions.checkArgument(StringUtils.isNotEmpty(fileId), "fileId should not be null"); + String url = _baseUrl + _filesPath + "/" + fileId; + ResponseWrapper response = _httpClient.sendGet(url); + LOG.info("queryFile:{}", response); + return response.responseContent; + } + + public ResponseWrapper deleteFile(String fileId) throws APIConnectionException, APIRequestException { + Preconditions.checkArgument(StringUtils.isNotEmpty(fileId), "fileId should not be null"); + String url = _baseUrl + _filesPath + "/" + fileId; + ResponseWrapper response = _httpClient.sendDelete(url); + LOG.info("deleteFile:{}", response); + return response; + } +} diff --git a/src/test/java/cn/jpush/api/files/FileClientTest.java b/src/test/java/cn/jpush/api/files/FileClientTest.java index 3de8fb0d..8151b628 100644 --- a/src/test/java/cn/jpush/api/files/FileClientTest.java +++ b/src/test/java/cn/jpush/api/files/FileClientTest.java @@ -79,6 +79,8 @@ public void testQueryFile() { @Test public void testDeleteFile() { FileClient fileClient = new FileClient(MASTER_SECRET, APP_KEY); + + try { fileClient.deleteFile(fileId); } catch (APIConnectionException e) { @@ -91,4 +93,8 @@ public void testDeleteFile() { LOG.info("Msg ID: " + e.getMsgId()); } } + + + + } From 6b2e38ca30dc77d22a9cee3f9374bf6a718fb02b Mon Sep 17 00:00:00 2001 From: zhanq Date: Thu, 1 Feb 2024 10:08:22 +0800 Subject: [PATCH 31/39] update version t0 3.7.4. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b4697d98..c2e68715 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.7.3 + 3.7.4 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client From 2ed1d4a6fa2395f6db2eeeeacf717a1a47331019 Mon Sep 17 00:00:00 2001 From: zhanq Date: Thu, 1 Feb 2024 10:11:14 +0800 Subject: [PATCH 32/39] update version t0 3.7.4. --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index c2e68715..ecc19e1b 100644 --- a/pom.xml +++ b/pom.xml @@ -299,8 +299,8 @@ ossrh https://oss.sonatype.org/ - - false + + true From 22873cf29907eec8cff53711c0215fc973c8b583 Mon Sep 17 00:00:00 2001 From: wicked_tc130 Date: Sun, 4 Feb 2024 17:21:18 +0800 Subject: [PATCH 33/39] update common version to 1.2.4. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ecc19e1b..84721c10 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ cn.jpush.api jiguang-common - 1.2.3 + 1.2.4 org.apache.httpcomponents From 40d08eae71b877903fd45df9e6253a6ff7789de2 Mon Sep 17 00:00:00 2001 From: wicked_tc130 Date: Sun, 4 Feb 2024 17:24:00 +0800 Subject: [PATCH 34/39] update common version to 1.2.5. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 84721c10..ed5a8aa8 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ cn.jpush.api jiguang-common - 1.2.4 + 1.2.5 org.apache.httpcomponents From 87aed55c8352661489ae957b4112a6058af20ccf Mon Sep 17 00:00:00 2001 From: wicked_tc130 Date: Sun, 4 Feb 2024 17:27:39 +0800 Subject: [PATCH 35/39] update version to 3.7.5. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ed5a8aa8..5724e6f3 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.7.4 + 3.7.5 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client From 41d9ef8c5eeeff2bc785b52ce4e43765c8880b48 Mon Sep 17 00:00:00 2001 From: wicked_tc130 Date: 2024年2月22日 17:27:11 +0800 Subject: [PATCH 36/39] update version to 3.7.6. --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5724e6f3..1a726a49 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.7.5 + 3.7.6 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client @@ -51,7 +51,7 @@ cn.jpush.api jiguang-common - 1.2.5 + 1.2.6 org.apache.httpcomponents From 48578bee8f38444835d78c690d3ebf173a36b1ea Mon Sep 17 00:00:00 2001 From: wicked_tc130 Date: 2024年5月29日 14:23:27 +0800 Subject: [PATCH 37/39] update version to 3.7.7. --- pom.xml | 4 +- .../jpush/api/push/model/Notification3rd.java | 2 +- .../cn/jpush/api/push/model/Platform.java | 30 ++-- .../model/notification/HmosNotification.java | 168 ++++++++++++++++++ .../push/model/notification/Notification.java | 5 +- .../notification/WinphoneNotification.java | 103 ----------- .../cn/jpush/api/push/PushClientTest.java | 29 +++ .../cn/jpush/api/push/mock/BaseMockTest.java | 2 +- .../api/push/mock/ResponseErrorTest.java | 18 +- ...ionTest.java => HmosNotificationTest.java} | 18 +- .../model/notification/NotificationTest.java | 10 +- .../api/push/remote/AlertOverrideTest.java | 10 +- .../api/push/remote/BasicFunctionsTest.java | 29 +-- .../jpush/api/push/remote/ExceptionTest.java | 37 +--- 14 files changed, 263 insertions(+), 202 deletions(-) create mode 100644 src/main/java/cn/jpush/api/push/model/notification/HmosNotification.java delete mode 100644 src/main/java/cn/jpush/api/push/model/notification/WinphoneNotification.java rename src/test/java/cn/jpush/api/push/model/notification/{WinphoneNotificationTest.java => HmosNotificationTest.java} (61%) diff --git a/pom.xml b/pom.xml index 1a726a49..9ee04b4b 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ cn.jpush.api jpush-client - 3.7.6 + 3.7.7 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client @@ -51,7 +51,7 @@ cn.jpush.api jiguang-common - 1.2.6 + 1.2.7 org.apache.httpcomponents diff --git a/src/main/java/cn/jpush/api/push/model/Notification3rd.java b/src/main/java/cn/jpush/api/push/model/Notification3rd.java index 8a6f622b..ef78e8ad 100644 --- a/src/main/java/cn/jpush/api/push/model/Notification3rd.java +++ b/src/main/java/cn/jpush/api/push/model/Notification3rd.java @@ -14,7 +14,7 @@ * 使用说明 * notification_3rd 只针对开通了厂商通道的用户生效; * notification 和 notification_3rd 不能同时有内容,如果这两块同时有内容,则会返回错误提示; - * notification_3rd 的内容对 iOS 和 WinPhone 平台无效,只针对 Android 平台生效; + * notification_3rd 的内容对 iOS 和 HMOS 平台无效,只针对 Android 平台生效; * notification_3rd 是用作补发厂商通知的内容,只有当 message 部分有内容,才允许传递此字段,且要两者都不为空时,才会对离线的厂商设备转发厂商通道的通知。 */ public class Notification3rd implements PushModel{ diff --git a/src/main/java/cn/jpush/api/push/model/Platform.java b/src/main/java/cn/jpush/api/push/model/Platform.java index 406bf35a..eddeff42 100644 --- a/src/main/java/cn/jpush/api/push/model/Platform.java +++ b/src/main/java/cn/jpush/api/push/model/Platform.java @@ -12,7 +12,7 @@ /** * https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#platform * - * JPush 当前支持 Android, iOS, QuickApp,Windows Phone 四个平台的推送。其关键字分别为:"android", "ios", "quickapp","winphone"。 + * JPush 当前支持 Android, iOS, QuickApp, HMOS 四个平台的推送。其关键字分别为:"android", "ios", "quickapp","hmos"。 * 使用方法,只需要在PushPayload中调用setPlatform方法。如:setPlatform(Platform.android_ios()) * 如需要全平台推送,只需要setPlatform(Platform.all()) */ @@ -47,8 +47,8 @@ public static Platform quickapp() { return newBuilder().addDeviceType(DeviceType.QuickApp).build(); } - public static Platform winphone() { - return newBuilder().addDeviceType(DeviceType.WinPhone).build(); + public static Platform hmos() { + return newBuilder().addDeviceType(DeviceType.HMOS).build(); } public static Platform android_ios() { @@ -58,17 +58,17 @@ public static Platform android_ios() { .build(); } - public static Platform android_winphone() { + public static Platform android_hmos() { return newBuilder() .addDeviceType(DeviceType.Android) - .addDeviceType(DeviceType.WinPhone) + .addDeviceType(DeviceType.HMOS) .build(); } - public static Platform ios_winphone() { + public static Platform ios_hmos() { return newBuilder() .addDeviceType(DeviceType.IOS) - .addDeviceType(DeviceType.WinPhone) + .addDeviceType(DeviceType.HMOS) .build(); } @@ -86,10 +86,10 @@ public static Platform ios_quickapp() { .build(); } - public static Platform quickapp_winphone() { + public static Platform quickapp_hmos() { return newBuilder() .addDeviceType(DeviceType.QuickApp) - .addDeviceType(DeviceType.WinPhone) + .addDeviceType(DeviceType.HMOS) .build(); } @@ -101,27 +101,27 @@ public static Platform android_ios_quickapp() { .build(); } - public static Platform android_ios_winphone() { + public static Platform android_ios_hmos() { return newBuilder() .addDeviceType(DeviceType.Android) .addDeviceType(DeviceType.IOS) - .addDeviceType(DeviceType.WinPhone) + .addDeviceType(DeviceType.HMOS) .build(); } - public static Platform android_quickapp_winphone() { + public static Platform android_quickapp_hmos() { return newBuilder() .addDeviceType(DeviceType.Android) .addDeviceType(DeviceType.QuickApp) - .addDeviceType(DeviceType.WinPhone) + .addDeviceType(DeviceType.HMOS) .build(); } - public static Platform ios_quickapp_winphone() { + public static Platform ios_quickapp_hmos() { return newBuilder() .addDeviceType(DeviceType.IOS) .addDeviceType(DeviceType.QuickApp) - .addDeviceType(DeviceType.WinPhone) + .addDeviceType(DeviceType.HMOS) .build(); } diff --git a/src/main/java/cn/jpush/api/push/model/notification/HmosNotification.java b/src/main/java/cn/jpush/api/push/model/notification/HmosNotification.java new file mode 100644 index 00000000..71e9135e --- /dev/null +++ b/src/main/java/cn/jpush/api/push/model/notification/HmosNotification.java @@ -0,0 +1,168 @@ +package cn.jpush.api.push.model.notification; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; + +import java.util.Map; + +/** + *

        HMOS Phone 通知类

        + *
        + * 具体使用方法请参考官方文档 https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#platform + * 支持 HMOS Notification 的参数: + *
          + *
        • alert: 继承自父类 PlatformNotification 的 alert 属性;本类设置则覆盖。
        • + *
        • title: 支持 setTitle(string) 方法来设置;可替换通知标题。
        • + *
        • _open_page: 支持 setOpenPage(String) 方法来设置;可设置点击打开的页面名称
        • + *
        • extras: 继承自父类 PlatformNotification 的 extras 属性;支持通过 addExtra(key, value) 来添加自定义字段,具体看代码。
        • + *
        + *
        + */ +public class HmosNotification extends PlatformNotification { + private static final String NOTIFICATION_HMOS = "hmos"; + + private static final String TITLE = "title"; + private static final String CATEGORY = "category"; + private static final String LARGE_ICON = "large_icon"; + private static final String INTENT = "intent"; + private static final String BADGE_ADD_NUM = "badge_add_num"; + private static final String TEST_MESSAGE = "test_message"; + private static final String RECEIPT_ID = "receipt_id"; + + private final String title; + private final String category; + private final String large_icon; + private final JsonObject intent; + private final Integer badge_add_num; + private final Boolean test_message; + private final String receipt_id; + + private HmosNotification(Object alert, + String title, + String category, + String large_icon, + JsonObject intent, + Integer badge_add_num, + Boolean test_message, + String receipt_id, + Map extras, + Map numberExtras, + Map booleanExtras, + Map jsonExtras, + Map customData) { + super(alert, extras, numberExtras, booleanExtras, jsonExtras, customData); + + this.title = title; + this.category = category; + this.large_icon = large_icon; + this.intent = intent; + this.badge_add_num = badge_add_num; + this.test_message = test_message; + this.receipt_id = receipt_id; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public static HmosNotification alert(String alert) { + return newBuilder().setAlert(alert).build(); + } + + + @Override + public String getPlatform() { + return NOTIFICATION_HMOS; + } + + @Override + public JsonElement toJSON() { + JsonObject json = super.toJSON().getAsJsonObject(); + + if (null != title) { + json.add(TITLE, new JsonPrimitive(title)); + } + if (null != category) { + json.add(CATEGORY, new JsonPrimitive(category)); + } + if (null != large_icon) { + json.add(LARGE_ICON, new JsonPrimitive(large_icon)); + } + if (null != intent) { + json.add(INTENT, intent); + } + if (null != badge_add_num) { + json.add(BADGE_ADD_NUM, new JsonPrimitive(badge_add_num)); + } + if (null != test_message) { + json.add(TEST_MESSAGE, new JsonPrimitive(test_message)); + } + if (null != receipt_id) { + json.add(RECEIPT_ID, new JsonPrimitive(receipt_id)); + } + return json; + } + + + public static class Builder extends PlatformNotification.Builder { + private String title; + private String category; + private String large_icon; + private JsonObject intent; + private Integer badge_add_num; + private Boolean test_message; + private String receipt_id; + + @Override + protected Builder getThis() { + return this; + } + + @Override + public Builder setAlert(Object alert) { + this.alert = alert; + return this; + } + + public Builder setTitle(String title) { + this.title = title; + return this; + } + + public Builder setCategory(String category) { + this.category = category; + return this; + } + + public Builder setLarge_icon(String large_icon) { + this.large_icon = large_icon; + return this; + } + + public Builder setIntent(JsonObject intent) { + this.intent = intent; + return this; + } + + public Builder setBadge_add_num(Integer badge_add_num) { + this.badge_add_num = badge_add_num; + return this; + } + + public Builder setTest_message(Boolean test_message) { + this.test_message = test_message; + return this; + } + + public Builder setReceipt_id(String receipt_id) { + this.receipt_id = receipt_id; + return this; + } + + public HmosNotification build() { + return new HmosNotification(alert, title, category,large_icon,intent,badge_add_num,test_message,receipt_id, + extrasBuilder, numberExtrasBuilder, booleanExtrasBuilder, jsonExtrasBuilder, super.customData); + } + } +} diff --git a/src/main/java/cn/jpush/api/push/model/notification/Notification.java b/src/main/java/cn/jpush/api/push/model/notification/Notification.java index 2a9782cf..2da780ca 100644 --- a/src/main/java/cn/jpush/api/push/model/notification/Notification.java +++ b/src/main/java/cn/jpush/api/push/model/notification/Notification.java @@ -99,10 +99,11 @@ public static Notification ios_incr_badge(int badge) { .build(); } - public static Notification winphone(String alert, Map extras) { + public static Notification hmos(String alert, String title, Map extras) { return newBuilder() - .addPlatformNotification(WinphoneNotification.newBuilder() + .addPlatformNotification(HmosNotification.newBuilder() .setAlert(alert) + .setTitle(title) .addExtras(extras) .build()) .build(); diff --git a/src/main/java/cn/jpush/api/push/model/notification/WinphoneNotification.java b/src/main/java/cn/jpush/api/push/model/notification/WinphoneNotification.java deleted file mode 100644 index aaef3f3e..00000000 --- a/src/main/java/cn/jpush/api/push/model/notification/WinphoneNotification.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.jpush.api.push.model.notification; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; - -import java.util.Map; - -/** - *

        Windows Phone 通知类

        - *
        - * 具体使用方法请参考官方文档 https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#platform - * 支持 Winphone Notification 的参数: - *
          - *
        • alert: 继承自父类 PlatformNotification 的 alert 属性;本类设置则覆盖。
        • - *
        • title: 支持 setTitle(string) 方法来设置;可替换通知标题。
        • - *
        • _open_page: 支持 setOpenPage(String) 方法来设置;可设置点击打开的页面名称
        • - *
        • extras: 继承自父类 PlatformNotification 的 extras 属性;支持通过 addExtra(key, value) 来添加自定义字段,具体看代码。
        • - *
        - *
        - */ -public class WinphoneNotification extends PlatformNotification { - private static final String NOTIFICATION_WINPHONE = "winphone"; - - private static final String TITLE = "title"; - private static final String _OPEN_PAGE = "_open_page"; - - private final String title; - private final String openPage; - - private WinphoneNotification(Object alert, String title, String openPage, - Map extras, - Map numberExtras, - Map booleanExtras, - Map jsonExtras, - Map customData) { - super(alert, extras, numberExtras, booleanExtras, jsonExtras, customData); - - this.title = title; - this.openPage = openPage; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public static WinphoneNotification alert(String alert) { - return newBuilder().setAlert(alert).build(); - } - - - @Override - public String getPlatform() { - return NOTIFICATION_WINPHONE; - } - - @Override - public JsonElement toJSON() { - JsonObject json = super.toJSON().getAsJsonObject(); - - if (null != title) { - json.add(TITLE, new JsonPrimitive(title)); - } - if (null != openPage) { - json.add(_OPEN_PAGE, new JsonPrimitive(openPage)); - } - - return json; - } - - - public static class Builder extends PlatformNotification.Builder { - private String title; - private String openPage; - - @Override - protected Builder getThis() { - return this; - } - - public Builder setTitle(String title) { - this.title = title; - return this; - } - - public Builder setOpenPage(String openPage) { - this.openPage = openPage; - return this; - } - - @Override - public Builder setAlert(Object alert) { - this.alert = alert; - return this; - } - - - public WinphoneNotification build() { - return new WinphoneNotification(alert, title, openPage, - extrasBuilder, numberExtrasBuilder, booleanExtrasBuilder, jsonExtrasBuilder, super.customData); - } - } -} diff --git a/src/test/java/cn/jpush/api/push/PushClientTest.java b/src/test/java/cn/jpush/api/push/PushClientTest.java index 9da4c23b..0453a462 100644 --- a/src/test/java/cn/jpush/api/push/PushClientTest.java +++ b/src/test/java/cn/jpush/api/push/PushClientTest.java @@ -13,7 +13,9 @@ import cn.jpush.api.push.model.Platform; import cn.jpush.api.push.model.audience.Audience; import cn.jpush.api.push.model.notification.*; +import com.google.gson.JsonObject; import io.netty.handler.codec.http.HttpMethod; +import lombok.SneakyThrows; import org.junit.Test; import cn.jiguang.common.connection.HttpProxy; @@ -231,4 +233,31 @@ public void testAlertType(){ System.out.println(notification.toJSON()); } + @Test + @SneakyThrows + public void testHmos(){ + JsonObject intentJson = new JsonObject(); + intentJson.addProperty("url","scheme://hmos?key1=val1&key2=val2"); + Notification notification = Notification.newBuilder() + .addPlatformNotification(HmosNotification.newBuilder() + .setAlert("hmos内容") + .setTitle("hmos标题") + .setCategory("IM") + .setLarge_icon("https://www.jiguang.cn/largeIcon.jpg") + .setIntent(intentJson) + .setBadge_add_num(1) + .setTest_message(false) + .setReceipt_id("receipt_id_2024") + .addExtra("a","a") + .build() + ).build(); + JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY); + PushPayload payload = PushPayload.newBuilder() + .setAudience(Audience.all()) + .setPlatform(Platform.hmos()) + .setNotification(notification) + .build(); + jpushClient.sendPush(payload); + } + } diff --git a/src/test/java/cn/jpush/api/push/mock/BaseMockTest.java b/src/test/java/cn/jpush/api/push/mock/BaseMockTest.java index f04d831b..2ff188e8 100644 --- a/src/test/java/cn/jpush/api/push/mock/BaseMockTest.java +++ b/src/test/java/cn/jpush/api/push/mock/BaseMockTest.java @@ -30,7 +30,7 @@ public class BaseMockTest implements IMockTest { static { SUPPORT_PLATFORM.add("android"); SUPPORT_PLATFORM.add("ios"); - SUPPORT_PLATFORM.add("winphone"); + SUPPORT_PLATFORM.add("hmos"); SUPPORT_AUDIENCE.add("tag"); SUPPORT_AUDIENCE.add("tag_and"); diff --git a/src/test/java/cn/jpush/api/push/mock/ResponseErrorTest.java b/src/test/java/cn/jpush/api/push/mock/ResponseErrorTest.java index 537cef39..e4641414 100644 --- a/src/test/java/cn/jpush/api/push/mock/ResponseErrorTest.java +++ b/src/test/java/cn/jpush/api/push/mock/ResponseErrorTest.java @@ -112,13 +112,13 @@ public void invalidParams_notification_ios() { } @Test - public void invalidParams_notification_winphone() { + public void invalidParams_notification_hmos() { JsonObject payload = new JsonObject(); payload.add("platform", Platform.all().toJSON()); payload.add("audience", Audience.all().toJSON()); JsonObject notification = new JsonObject(); - notification.add("winphone", new JsonPrimitive(ALERT)); + notification.add("hmos", new JsonPrimitive(ALERT)); payload.add("notification", notification); System.out.println("json string: " + payload.toString()); @@ -219,15 +219,15 @@ public void lackOfParams_notification_ios_empty() { } @Test - public void lackOfParams_notification_winphone_empty() { + public void lackOfParams_notification_hmos_empty() { JsonObject payload = new JsonObject(); payload.add("platform", Platform.all().toJSON()); payload.add("audience", Audience.all().toJSON()); JsonObject notification = new JsonObject(); - JsonObject winphone = new JsonObject(); + JsonObject hmos = new JsonObject(); - notification.add("winphone", winphone); + notification.add("hmos", hmos); payload.add("notification", notification); System.out.println("json string: " + payload.toString()); @@ -275,16 +275,16 @@ public void lackOfParams_notification_ios_noalert() { } @Test - public void lackOfParams_notification_winphone_noalert() { + public void lackOfParams_notification_hmos_noalert() { JsonObject payload = new JsonObject(); payload.add("platform", Platform.all().toJSON()); payload.add("audience", Audience.all().toJSON()); JsonObject notification = new JsonObject(); - JsonObject winphone = new JsonObject(); - winphone.add("title", new JsonPrimitive("title")); + JsonObject hmos = new JsonObject(); + hmos.add("title", new JsonPrimitive("title")); - notification.add("winphone", winphone); + notification.add("hmos", hmos); payload.add("notification", notification); System.out.println("json string: " + payload.toString()); diff --git a/src/test/java/cn/jpush/api/push/model/notification/WinphoneNotificationTest.java b/src/test/java/cn/jpush/api/push/model/notification/HmosNotificationTest.java similarity index 61% rename from src/test/java/cn/jpush/api/push/model/notification/WinphoneNotificationTest.java rename to src/test/java/cn/jpush/api/push/model/notification/HmosNotificationTest.java index 9cadb938..bbee925a 100644 --- a/src/test/java/cn/jpush/api/push/model/notification/WinphoneNotificationTest.java +++ b/src/test/java/cn/jpush/api/push/model/notification/HmosNotificationTest.java @@ -10,33 +10,33 @@ import com.google.gson.JsonPrimitive; @Category(FastTests.class) -public class WinphoneNotificationTest { +public class HmosNotificationTest { @Test public void testEmpty() { - WinphoneNotification winphone = WinphoneNotification.newBuilder().build(); - Assert.assertEquals("", new JsonObject(), winphone.toJSON()); + HmosNotification hmos = HmosNotification.newBuilder().build(); + Assert.assertEquals("", new JsonObject(), hmos.toJSON()); } @Test public void testQuickAlert() { - WinphoneNotification winphone = WinphoneNotification.alert("aaa"); + HmosNotification hmos = HmosNotification.alert("aaa"); JsonObject json = new JsonObject(); json.add("alert", new JsonPrimitive("aaa")); - Assert.assertEquals("", json, winphone.toJSON()); + Assert.assertEquals("", json, hmos.toJSON()); } @Test public void testTitle() { - WinphoneNotification winphone = WinphoneNotification.newBuilder().setTitle("title").build(); + HmosNotification hmos = HmosNotification.newBuilder().setTitle("title").build(); JsonObject json = new JsonObject(); json.add("title", new JsonPrimitive("title")); - Assert.assertEquals("", json, winphone.toJSON()); + Assert.assertEquals("", json, hmos.toJSON()); } @Test public void testExtra() { - WinphoneNotification winphone = WinphoneNotification.newBuilder() + HmosNotification hmos = HmosNotification.newBuilder() .addExtra("key2", 222) .addExtra("key", "value").build(); JsonObject json = new JsonObject(); @@ -44,7 +44,7 @@ public void testExtra() { extra.add("key", new JsonPrimitive("value")); extra.add("key2", new JsonPrimitive(222)); json.add("extras", extra); - Assert.assertEquals("", json, winphone.toJSON()); + Assert.assertEquals("", json, hmos.toJSON()); } diff --git a/src/test/java/cn/jpush/api/push/model/notification/NotificationTest.java b/src/test/java/cn/jpush/api/push/model/notification/NotificationTest.java index 666e054b..c2bdbfe1 100644 --- a/src/test/java/cn/jpush/api/push/model/notification/NotificationTest.java +++ b/src/test/java/cn/jpush/api/push/model/notification/NotificationTest.java @@ -64,15 +64,15 @@ public void testAlert_ios() { } @Test - public void testAlert_winphone() { + public void testAlert_hmos() { Notification notification = Notification.newBuilder() - .addPlatformNotification(WinphoneNotification.alert("alert")) + .addPlatformNotification(HmosNotification.alert("alert")) .build(); JsonObject json = new JsonObject(); - JsonObject winphone = new JsonObject(); - winphone.add("alert", new JsonPrimitive("alert")); + JsonObject hmos = new JsonObject(); + hmos.add("alert", new JsonPrimitive("alert")); json.addProperty("ai_opportunity", false); - json.add("winphone", winphone); + json.add("hmos", hmos); Assert.assertEquals("", json, notification.toJSON()); } diff --git a/src/test/java/cn/jpush/api/push/remote/AlertOverrideTest.java b/src/test/java/cn/jpush/api/push/remote/AlertOverrideTest.java index 298eab51..dcc24ace 100644 --- a/src/test/java/cn/jpush/api/push/remote/AlertOverrideTest.java +++ b/src/test/java/cn/jpush/api/push/remote/AlertOverrideTest.java @@ -14,7 +14,7 @@ import cn.jpush.api.push.model.notification.AndroidNotification; import cn.jpush.api.push.model.notification.IosNotification; import cn.jpush.api.push.model.notification.Notification; -import cn.jpush.api.push.model.notification.WinphoneNotification; +import cn.jpush.api.push.model.notification.HmosNotification; @Category(SlowTests.class) public class AlertOverrideTest extends BaseRemotePushTest { @@ -28,7 +28,7 @@ public void sendAlert_all() throws Exception { .setAlert("alert") .addPlatformNotification(AndroidNotification.alert("android alert")) .addPlatformNotification(IosNotification.alert("ios alert")) - .addPlatformNotification(WinphoneNotification.alert("winphone alert")) + .addPlatformNotification(HmosNotification.alert("hmos alert")) .build()) .build(); PushResult result = _client.sendPush(payload); @@ -67,13 +67,13 @@ public void sendAlert_ios() throws Exception { } @Test - public void sendAlert_wp() throws Exception { + public void sendAlert_hmos() throws Exception { PushPayload payload = PushPayload.newBuilder() - .setPlatform(Platform.winphone()) + .setPlatform(Platform.hmos()) .setAudience(Audience.all()) .setNotification(Notification.newBuilder() .setAlert("alert") - .addPlatformNotification(WinphoneNotification.alert("winphone alert")) + .addPlatformNotification(HmosNotification.alert("hmos alert")) .build()) .build(); try { diff --git a/src/test/java/cn/jpush/api/push/remote/BasicFunctionsTest.java b/src/test/java/cn/jpush/api/push/remote/BasicFunctionsTest.java index 835a73e9..bc541daa 100644 --- a/src/test/java/cn/jpush/api/push/remote/BasicFunctionsTest.java +++ b/src/test/java/cn/jpush/api/push/remote/BasicFunctionsTest.java @@ -2,7 +2,6 @@ import static org.junit.Assert.assertTrue; -import cn.jiguang.common.resp.APIConnectionException; import cn.jiguang.common.resp.APIRequestException; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -17,7 +16,7 @@ import cn.jpush.api.push.model.notification.AndroidNotification; import cn.jpush.api.push.model.notification.IosNotification; import cn.jpush.api.push.model.notification.Notification; -import cn.jpush.api.push.model.notification.WinphoneNotification; +import cn.jpush.api.push.model.notification.HmosNotification; @Category(SlowTests.class) public class BasicFunctionsTest extends BaseRemotePushTest { @@ -88,12 +87,12 @@ public void sendSimpleNotification_Pall_Nios() throws Exception { } @Test - public void sendSimpleNotification_Pwp_Nwp() throws Exception { + public void sendSimpleNotification_Phmos_Nhmos() throws Exception { PushPayload payload = PushPayload.newBuilder() - .setPlatform(Platform.winphone()) + .setPlatform(Platform.hmos()) .setAudience(Audience.all()) .setNotification(Notification.newBuilder() - .addPlatformNotification(WinphoneNotification.alert("Pwp Nwp alert")) + .addPlatformNotification(HmosNotification.alert("Phmos Nhmos alert")) .build()) .build(); try { @@ -104,12 +103,12 @@ public void sendSimpleNotification_Pwp_Nwp() throws Exception { } @Test - public void sendSimpleNotification_Pall_Nwp() throws Exception { + public void sendSimpleNotification_Pall_Nhmos() throws Exception { PushPayload payload = PushPayload.newBuilder() .setPlatform(Platform.all()) .setAudience(Audience.all()) .setNotification(Notification.newBuilder() - .addPlatformNotification(WinphoneNotification.alert("Pall Nwp alert")) + .addPlatformNotification(HmosNotification.alert("Pall Nhmos alert")) .build()) .build(); try { @@ -125,11 +124,11 @@ public void sendSimpleNotification_Pall_Nall() throws Exception { PushPayload payload = PushPayload.newBuilder() .setPlatform(Platform.newBuilder() .addDeviceType(DeviceType.IOS) - .addDeviceType(DeviceType.WinPhone) + .addDeviceType(DeviceType.HMOS) .addDeviceType(DeviceType.Android).build()) .setAudience(Audience.all()) .setNotification(Notification.newBuilder() - .addPlatformNotification(WinphoneNotification.alert("Pall Nall wp alert")) + .addPlatformNotification(HmosNotification.alert("Pall Nall hmos alert")) .addPlatformNotification(IosNotification.alert("Pall Nall ios alert")) .addPlatformNotification(AndroidNotification.alert("Pall Nall android alert")) .build()) @@ -169,18 +168,6 @@ public void sendSimpleMessage_Pios() throws Exception { e.printStackTrace(); } } - - //@Test - public void sendSimpleMessage_Pwinphone() throws Exception { - PushPayload payload = PushPayload.newBuilder() - .setPlatform(Platform.winphone()) - .setAudience(Audience.all()) - .setMessage(Message.content("Pwp msg")) - .build(); - PushResult result = _client.sendPush(payload); - assertTrue(result.isResultOK()); - } - @Test public void sendSimpleMessageAndNotification_Pall() throws Exception { diff --git a/src/test/java/cn/jpush/api/push/remote/ExceptionTest.java b/src/test/java/cn/jpush/api/push/remote/ExceptionTest.java index 1d307fa0..e92ac55a 100644 --- a/src/test/java/cn/jpush/api/push/remote/ExceptionTest.java +++ b/src/test/java/cn/jpush/api/push/remote/ExceptionTest.java @@ -160,28 +160,7 @@ public void invalidParams_notification_ios() { assertEquals(INVALID_PARAMS, e.getErrorCode()); } } - /* - @Test - public void invalidParams_notification_winphone() { - JsonObject payload = new JsonObject(); - payload.add("platform", Platform.all().toJSON()); - payload.add("audience", Audience.all().toJSON()); - - JsonObject notification = new JsonObject(); - notification.add("winphone", new JsonPrimitive(ALERT)); - payload.add("notification", notification); - - System.out.println("json string: " + payload.toString()); - - try { - _client.sendPush(payload.toString()); - } catch (APIConnectionException e) { - e.printStackTrace(); - } catch (APIRequestException e) { - assertEquals(INVALID_PARAMS, e.getErrorCode()); - } - } - */ + @Test public void invalidParams_notification_android_builderidNotNumber() { JsonObject payload = new JsonObject(); @@ -254,15 +233,15 @@ public void invalidParams_notification_ios_empty() { } @Test - public void invalidParams_notification_winphone_empty() { + public void invalidParams_notification_hmos_empty() { JsonObject payload = new JsonObject(); payload.add("platform", Platform.all().toJSON()); payload.add("audience", Audience.all().toJSON()); JsonObject notification = new JsonObject(); - JsonObject winphone = new JsonObject(); + JsonObject hmos = new JsonObject(); - notification.add("winphone", winphone); + notification.add("hmos", hmos); payload.add("notification", notification); System.out.println("json string: " + payload.toString()); @@ -326,16 +305,16 @@ public void invalidParams_notification_ios_noalert() { } @Test - public void invalidParams_notification_winphone_noalert() { + public void invalidParams_notification_hmos_noalert() { JsonObject payload = new JsonObject(); payload.add("platform", Platform.all().toJSON()); payload.add("audience", Audience.all().toJSON()); JsonObject notification = new JsonObject(); - JsonObject winphone = new JsonObject(); - winphone.add("title", new JsonPrimitive("title")); + JsonObject hmos = new JsonObject(); + hmos.add("title", new JsonPrimitive("title")); - notification.add("winphone", winphone); + notification.add("hmos", hmos); payload.add("notification", notification); System.out.println("json string: " + payload.toString()); From 88a4472e57f2c8f5be2223d7a7367c9e7fca194e Mon Sep 17 00:00:00 2001 From: wicked_tc130 Date: Fri, 7 Jun 2024 11:02:03 +0800 Subject: [PATCH 38/39] update version to 3.7.8. --- pom.xml | 224 +----------------- .../java/cn/jpush/api/push/model/Message.java | 16 +- 2 files changed, 15 insertions(+), 225 deletions(-) diff --git a/pom.xml b/pom.xml index 9ee04b4b..7a3330df 100644 --- a/pom.xml +++ b/pom.xml @@ -3,20 +3,12 @@ cn.jpush.api jpush-client - 3.7.7 + 3.7.8 jar https://github.com/jpush/jpush-api-java-client JPush API Java Client JPush's officially supported Java client library for accessing JPush APIs. - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - github UTF-8 @@ -131,218 +123,4 @@
        - - - - maven-compiler-plugin - 3.1 - - ${jdkVersion} - ${jdkVersion} - 1.5 - true - true - true - true - - -Xlint:unchecked - - - - - - org.apache.maven.plugins - maven-release-plugin - 2.5.1 - - - org.apache.maven.plugins - maven-scm-plugin - 1.9.2 - - - - deploy,site - false - true - true - v@{project.version} - - - - - com.github.github - site-maven-plugin - 0.9 - - Creating site for ${project.version} - github - - - - - site - - site - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.17 - - cn.jpush.api.FastTests - -Dfile.encoding=UTF-8 - - **/mock/*Test.java - - - - - org.apache.maven.surefire - surefire-junit47 - 2.17 - - - - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.17 - - UTF-8 - cn.jpush.api.SlowTests - -Dfile.encoding=UTF-8 - - **/mock/*Test.java - - - - - - integration-test - verify - - - - **/*.class - - - - - - - org.apache.maven.surefire - surefire-junit47 - 2.17 - - - - - - - - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - - attach-javadocs - - jar - - - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ossrh - https://oss.sonatype.org/ - - true - - - - - - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots/ - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.8 - - - - dependencies - license - scm - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.3 - - resources/javadoc-overview.html - - - - - - diff --git a/src/main/java/cn/jpush/api/push/model/Message.java b/src/main/java/cn/jpush/api/push/model/Message.java index 822f8a74..b87f5b6a 100644 --- a/src/main/java/cn/jpush/api/push/model/Message.java +++ b/src/main/java/cn/jpush/api/push/model/Message.java @@ -22,18 +22,20 @@ public class Message implements PushModel { private static final String MSG_CONTENT = "msg_content"; private static final String TITLE = "title"; private static final String CONTENT_TYPE = "content_type"; + private static final String TEST_MESSAGE = "test_message"; private static final String EXTRAS = "extras"; private final String msgContent; private final String title; private final String contentType; + private final Boolean testMessage; private final Map extras; private final Map numberExtras; private final Map booleanExtras; private final Map jsonExtras; private final Map customData; - private Message(String title, String msgContent, String contentType, + private Message(String title, String msgContent, String contentType, Boolean testMessage, Map extras, Map numberExtras, Map booleanExtras, @@ -42,6 +44,7 @@ private Message(String title, String msgContent, String contentType, this.title = title; this.msgContent = msgContent; this.contentType = contentType; + this.testMessage = testMessage; this.extras = extras; this.numberExtras = numberExtras; this.booleanExtras = booleanExtras; @@ -69,6 +72,9 @@ public JsonElement toJSON() { if (null != contentType) { json.add(CONTENT_TYPE, new JsonPrimitive(contentType)); } + if (null != testMessage) { + json.add(TEST_MESSAGE, new JsonPrimitive(testMessage)); + } JsonObject extrasObject = null; if (null != extras || null != numberExtras || null != booleanExtras || null != jsonExtras) { @@ -118,6 +124,7 @@ public static class Builder { private String title; private String msgContent; private String contentType; + private Boolean testMessage; private Map extrasBuilder; private Map numberExtrasBuilder; private Map booleanExtrasBuilder; @@ -139,6 +146,11 @@ public Builder setContentType(String contentType) { return this; } + public Builder setTestMessage(Boolean testMessage) { + this.testMessage = testMessage; + return this; + } + public Builder addExtra(String key, String value) { Preconditions.checkArgument(!(null == key || null == value), "Key/Value should not be null."); if (null == extrasBuilder) { @@ -226,7 +238,7 @@ public Builder addCustom(String key, Boolean value) { public Message build() { Preconditions.checkArgument(!(null == msgContent), "msgContent should be set"); - return new Message(title, msgContent, contentType, + return new Message(title, msgContent, contentType, testMessage, extrasBuilder, numberExtrasBuilder, booleanExtrasBuilder, jsonExtrasBuilder, customData); } } From 71ffa03d85d2712129516ea47e2d0440ca870a19 Mon Sep 17 00:00:00 2001 From: wicked-tc130 Date: 2024年7月17日 18:15:23 +0800 Subject: [PATCH 39/39] Update README.md --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1c99bf90..185e9c2e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,14 @@ -# 温馨提示 -极光已推出新版本的 SDK 供广大用户使用,当前版本后续将不推荐使用,请移步仓库 [jiguang-sdk-java](https://github.com/jpush/jiguang-sdk-java) 了解更多。 +# 新版 SDK +欢迎使用新一代 [jiguang-sdk-java](https://github.com/jpush/jiguang-sdk-java)!这个 SDK 旨在提供更好的性能、更多功能和更好的用户体验。 +为什么升级? +* 性能优化:新版本经过优化,运行更快,消耗更少的资源。 +* 功能增强:引入了许多新功能和改进,使您的开发工作更加高效。 +* Bug 修复:解决了上个版本存在的问题,提高了稳定性和可靠性。 + +> 极光已推出新版本的 SDK 供广大用户使用,当前版本后续将不推荐使用,请移步仓库 [jiguang-sdk-java](https://github.com/jpush/jiguang-sdk-java) 了解更多。 + +# ~~旧版 SDK~~ [![GitHub version](https://badge.fury.io/gh/jpush%2Fjpush-api-java-client.svg)](http://badge.fury.io/gh/jpush%2Fjpush-api-java-client)

        AltStyle によって変換されたページ (->オリジナル) /