From cfffca82fac28e99cde3eef720b8c2981f8c87d8 Mon Sep 17 00:00:00 2001 From: liupopo Date: Thu, 16 Mar 2023 18:27:38 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=86=E6=88=90=E4=B8=AA=E6=8E=A8SDK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/推送信息.txt | 13 +++ mallplus-admin/pom.xml | 7 ++ mallplus-portal/pom.xml | 6 + .../mallplus/unipush/UniPushService.java | 110 ++++++++++++++++++ .../src/main/resources/application.properties | 7 ++ 5 files changed, 143 insertions(+) create mode 100644 docs/推送信息.txt create mode 100644 mallplus-portal/src/main/java/com/zscat/mallplus/unipush/UniPushService.java diff --git a/docs/推送信息.txt b/docs/推送信息.txt new file mode 100644 index 0000000..c81cdbb --- /dev/null +++ b/docs/推送信息.txt @@ -0,0 +1,13 @@ + +APPID UBUIDJ8NQm50rGJsB6LYx1 +APPKEY RS3UZfeS509hcNEkmfS6R +AppSecret 6QuFcPWFga8DQzSa03ruR7 + MasterSecret 6fjUinwRfDA3BcEnDQvTl5 + + +Android 应用标识 org.jbase.yxt.yyd.pyw + + +https://docs.getui.com/getui/server/rest_v2/service_sdk/ + +https://github.com/GetuiLaboratory/getui-pushapi-java-client-v2 \ No newline at end of file diff --git a/mallplus-admin/pom.xml b/mallplus-admin/pom.xml index cea5f8b..3d8e5ac 100644 --- a/mallplus-admin/pom.xml +++ b/mallplus-admin/pom.xml @@ -195,6 +195,13 @@ easypoi-annotation 3.2.0 + + + com.getui.push + restful-sdk + 1.0.0.11 + + diff --git a/mallplus-portal/pom.xml b/mallplus-portal/pom.xml index 2045f67..1b5a753 100644 --- a/mallplus-portal/pom.xml +++ b/mallplus-portal/pom.xml @@ -204,6 +204,12 @@ wsdl4j 1.6.3 + + com.getui.push + restful-sdk + 1.0.0.11 + compile + diff --git a/mallplus-portal/src/main/java/com/zscat/mallplus/unipush/UniPushService.java b/mallplus-portal/src/main/java/com/zscat/mallplus/unipush/UniPushService.java new file mode 100644 index 0000000..8e063d1 --- /dev/null +++ b/mallplus-portal/src/main/java/com/zscat/mallplus/unipush/UniPushService.java @@ -0,0 +1,110 @@ +package com.zscat.mallplus.unipush; + +import com.getui.push.v2.sdk.ApiHelper; +import com.getui.push.v2.sdk.GtApiConfiguration; +import com.getui.push.v2.sdk.api.PushApi; +import com.getui.push.v2.sdk.common.ApiResult; +import com.getui.push.v2.sdk.dto.req.Audience; +import com.getui.push.v2.sdk.dto.req.message.PushChannel; +import com.getui.push.v2.sdk.dto.req.message.PushDTO; +import com.getui.push.v2.sdk.dto.req.message.PushMessage; +import com.getui.push.v2.sdk.dto.req.message.android.AndroidDTO; +import com.getui.push.v2.sdk.dto.req.message.android.GTNotification; +import org.springframework.stereotype.Component; + +import java.util.Map; + +@Component +public class UniPushService { + + + public void test() { + // 设置httpClient最大连接数,当并发较大时建议调大此参数。或者启动参数加上 -Dhttp.maxConnections=200 + System.setProperty("http.maxConnections", "200"); + GtApiConfiguration apiConfiguration = new GtApiConfiguration(); + //填写应用配置 + apiConfiguration.setAppId("UBUIDJ8NQm50rGJsB6LYx1"); + apiConfiguration.setAppKey("RS3UZfeS509hcNEkmfS6R"); + apiConfiguration.setMasterSecret("6fjUinwRfDA3BcEnDQvTl5"); + // 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId + apiConfiguration.setDomain("https://restapi.getui.com/v2/"); + // 实例化ApiHelper对象,用于创建接口对象 + ApiHelper apiHelper = ApiHelper.build(apiConfiguration); + // 创建对象,建议复用。目前有PushApi、StatisticApi、UserApi + PushApi pushApi = apiHelper.creatApi(PushApi.class); + + //根据cid进行单推 + PushDTO pushDTO = new PushDTO(); + // 设置推送参数 + pushDTO.setRequestId(System.currentTimeMillis() + ""); + /**** 设置个推通道参数 *****/ + PushMessage pushMessage = new PushMessage(); + pushDTO.setPushMessage(pushMessage); + GTNotification notification = new GTNotification(); + pushMessage.setNotification(notification); + notification.setTitle("测试TitleXXX"); + notification.setBody("测试BodyXXXXXX"); + String payload = "{\"title\":\"liutitle\",\"body\":\"liubody\",\"name\":\"hao\",\"userid\":101,\"msgtitle\":\"haha\"}"; + notification.setPayload(payload); + notification.setClickType("payload"); +// notification.setClickType("url"); +// notification.setUrl("https://www.getui.com"); + /**** 设置个推通道参数,更多参数请查看文档或对象源码 *****/ + +// /**** 设置厂商相关参数 ****/ +// PushChannel pushChannel = new PushChannel(); +// pushDTO.setPushChannel(pushChannel); +// /*配置安卓厂商参数*/ +// AndroidDTO androidDTO = new AndroidDTO(); +// pushChannel.setAndroid(androidDTO); +// Ups ups = new Ups(); +// androidDTO.setUps(ups); +// ThirdNotification thirdNotification = new ThirdNotification(); +// ups.setNotification(thirdNotification); +// thirdNotification.setTitle("厂商title"); +// thirdNotification.setBody("厂商body"); +// thirdNotification.setClickType("url"); +// thirdNotification.setUrl("https://www.getui.com"); +// // 两条消息的notify_id相同,新的消息会覆盖老的消息,取值范围:0-2147483647 +// // thirdNotification.setNotifyId("11177"); +// /*配置安卓厂商参数结束,更多参数请查看文档或对象源码*/ + +// /*设置ios厂商参数*/ +// IosDTO iosDTO = new IosDTO(); +// pushChannel.setIos(iosDTO); +// // 相同的collapseId会覆盖之前的消息 +// iosDTO.setApnsCollapseId("xxx"); +// Aps aps = new Aps(); +// iosDTO.setAps(aps); +// Alert alert = new Alert(); +// aps.setAlert(alert); +// alert.setTitle("ios title"); +// alert.setBody("ios body"); +// /*设置ios厂商参数结束,更多参数请查看文档或对象源码*/ + + /*设置接收人信息*/ + Audience audience = new Audience(); + pushDTO.setAudience(audience); + audience.addCid("89e286aee78d38faf748a690e603b1a3"); + /*设置接收人信息结束*/ + /**** 设置厂商相关参数,更多参数请查看文档或对象源码 ****/ + + // 进行cid单推 + ApiResult>> apiResult = pushApi.pushToSingleByCid(pushDTO); + if (apiResult.isSuccess()) { + // success + System.out.println(apiResult.getData()); + } else { + // failed + System.out.println("code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg()); + } + + } + + public static void main(String[] args) { + new UniPushService().test(); + } + + + +} diff --git a/mallplus-portal/src/main/resources/application.properties b/mallplus-portal/src/main/resources/application.properties index 7c28e74..26e4ee1 100644 --- a/mallplus-portal/src/main/resources/application.properties +++ b/mallplus-portal/src/main/resources/application.properties @@ -135,3 +135,10 @@ wxsubpay.partnerKey=xxxx wxsubpay.certPath=xxxx wxsubpay.domain=xxxx +unipush.baseurl=https://restapi.getui.com/v2/UBUIDJ8NQm50rGJsB6LYx1 +unipush.appid=UBUIDJ8NQm50rGJsB6LYx1 +unipush.appkey=RS3UZfeS509hcNEkmfS6R +unipush.appsecret=6QuFcPWFga8DQzSa03ruR7 +unipush.mastersecret=6fjUinwRfDA3BcEnDQvTl5 +unipush.apppackage=org.jbase.yxt.yyd.pyw +