fix-个推
This commit is contained in:
@@ -166,3 +166,16 @@ wechat:
|
||||
token: 111
|
||||
aesKey: 111
|
||||
webhook: 123 #机器人的key
|
||||
|
||||
lxk:
|
||||
push:
|
||||
getui:
|
||||
appId: i5f0UjWIAN6nTd15Vuyos3
|
||||
appKey: YJMSMNpTR1AQsecfR8i1s2
|
||||
appSecret: YJR223iLXN8G94jjVdLGx4
|
||||
masterSecret: WDd7By2frY9vGRrc1VPwa
|
||||
intent: intent://io.dcloud.unipush/?#Intent;scheme=unipush;launchFlags=0x4000000;component=io.dcloud.HBuilder/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title={0};S.content={1};S.payload=test;end
|
||||
jiguang:
|
||||
appkey: xxxxxxxxxxxxxxxxxxxxx
|
||||
secret: yyyyyyyyyyyyyyyyyyyy
|
||||
apns: false
|
||||
|
||||
@@ -341,6 +341,18 @@
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>weixin-java-cp</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.getui.push</groupId>
|
||||
<artifactId>restful-sdk</artifactId>
|
||||
<version>1.0.0.8</version>
|
||||
</dependency>
|
||||
<!-- 引入极光客户端依赖 -->
|
||||
<dependency>
|
||||
<groupId>cn.jpush.api</groupId>
|
||||
<artifactId>jpush-client</artifactId>
|
||||
<version>3.2.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.zbkj.common.config;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "lxk.push.getui")
|
||||
@Validated
|
||||
@Data
|
||||
@Slf4j
|
||||
public class GeTuiConfigProperties {
|
||||
|
||||
private String appId;
|
||||
private String appKey;
|
||||
private String appSecret;
|
||||
private String masterSecret;
|
||||
private String intent;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.zbkj.common.config;
|
||||
|
||||
import cn.jpush.api.JPushClient;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "lxk.push.jiguang")
|
||||
@Validated
|
||||
@Data
|
||||
@Slf4j
|
||||
public class JPushConfig {
|
||||
|
||||
private String appkey;
|
||||
private String secret;
|
||||
private boolean apns;
|
||||
|
||||
private JPushClient jPushClient;
|
||||
|
||||
|
||||
/**
|
||||
* 推送客户端
|
||||
* @return
|
||||
*/
|
||||
// @PostConstruct
|
||||
public void initJPushClient() {
|
||||
try {
|
||||
jPushClient = new JPushClient(secret, appkey);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取推送客户端
|
||||
* @return
|
||||
*/
|
||||
public JPushClient getJPushClient() {
|
||||
return jPushClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* 区分开发和线上环境
|
||||
* @return
|
||||
*/
|
||||
public boolean getApns() {
|
||||
return apns;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,4 +14,9 @@ public class ImConstants {
|
||||
//阅读状态 0=未读,1=已读
|
||||
public static final int READSTATUS_0 = 0;
|
||||
public static final int READSTATUS_1 = 1;
|
||||
|
||||
//编辑详情
|
||||
public static final Integer COMMON_TYPE_0 = 0;
|
||||
//外部链接
|
||||
public static final Integer COMMON_TYPE_1 = 1;
|
||||
}
|
||||
|
||||
@@ -242,4 +242,7 @@ public class User implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "用户编号")
|
||||
private Long userSn;
|
||||
|
||||
@ApiModelProperty(value = "个推cid")
|
||||
private String geTuiCid;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.zbkj.common.annotation.LogControllerAnnotation;
|
||||
import com.zbkj.common.constants.SmsConstants;
|
||||
import com.zbkj.common.enums.MethodType;
|
||||
import com.zbkj.common.exception.LxkException;
|
||||
import com.zbkj.common.model.user.User;
|
||||
import com.zbkj.common.request.*;
|
||||
import com.zbkj.common.request.pay.PayPasswordRequest;
|
||||
import com.zbkj.common.response.UserInfoResponse;
|
||||
@@ -24,10 +25,9 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* 用户 -- 用户中心
|
||||
@@ -152,6 +152,28 @@ public class UserController {
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户个推cid
|
||||
*
|
||||
* @param geTuiCid
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/update_getui_cid/{geTuiCid}")
|
||||
public CommonResult<Boolean> updateGetuiCid(@NotEmpty(message = "cid不能为空") @PathVariable String geTuiCid) {
|
||||
Integer uid = userService.getUserId();
|
||||
User user = userService.getById(uid);
|
||||
if (user == null) {
|
||||
throw new LxkException("用户不存在");
|
||||
}
|
||||
User update = new User();
|
||||
update.setId(uid);
|
||||
update.setGeTuiCid(geTuiCid);
|
||||
if (userService.updateById(update)) {
|
||||
return CommonResult.success();
|
||||
}
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
private void checkValidateCode(LoginMobileRequest request) {
|
||||
if (StrUtil.isBlank(request.getPhone()) && StrUtil.isBlank(request.getPhoneBase64())) {
|
||||
throw new LxkException("手机号不能为空");
|
||||
|
||||
@@ -155,3 +155,16 @@ wechat:
|
||||
token: 111
|
||||
aesKey: 111
|
||||
webhook: 123 #机器人的key
|
||||
|
||||
lxk:
|
||||
push:
|
||||
getui:
|
||||
appId: i5f0UjWIAN6nTd15Vuyos3
|
||||
appKey: YJMSMNpTR1AQsecfR8i1s2
|
||||
appSecret: YJR223iLXN8G94jjVdLGx4
|
||||
masterSecret: WDd7By2frY9vGRrc1VPwa
|
||||
intent: intent://io.dcloud.unipush/?#Intent;scheme=unipush;launchFlags=0x4000000;component=io.dcloud.HBuilder/io.dcloud.PandoraEntry;S.UP-OL-SU=true;S.title={0};S.content={1};S.payload=test;end
|
||||
jiguang:
|
||||
appkey: xxxxxxxxxxxxxxxxxxxxx
|
||||
secret: yyyyyyyyyyyyyyyyyyyy
|
||||
apns: false
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.zbkj.service.service;
|
||||
|
||||
import com.getui.push.v2.sdk.common.ApiResult;
|
||||
import com.getui.push.v2.sdk.dto.res.TaskIdDTO;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消息管理Service接口
|
||||
*
|
||||
* @author huahua
|
||||
* @date 2022-12-08
|
||||
*/
|
||||
public interface PushService {
|
||||
|
||||
ApiResult<Map<String, Map<String, String>>> push(String title, String body, Long id, String cid, Integer type, String url);
|
||||
|
||||
ApiResult<TaskIdDTO> pushAll(String title, String body, Long id, Integer type, String url);
|
||||
|
||||
ApiResult<Map<String, Map<String, String>>> uniPush(String title, String body, Long id, String cid, Integer type, String url, Integer category);
|
||||
|
||||
ApiResult<TaskIdDTO> uniPushAll(String title, String body, Long id, Integer type, String url, Integer category);
|
||||
}
|
||||
@@ -0,0 +1,333 @@
|
||||
package com.zbkj.service.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
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.CommonEnum;
|
||||
import com.getui.push.v2.sdk.dto.req.Audience;
|
||||
import com.getui.push.v2.sdk.dto.req.Settings;
|
||||
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 com.getui.push.v2.sdk.dto.req.message.android.ThirdNotification;
|
||||
import com.getui.push.v2.sdk.dto.req.message.android.Ups;
|
||||
import com.getui.push.v2.sdk.dto.req.message.ios.Alert;
|
||||
import com.getui.push.v2.sdk.dto.req.message.ios.Aps;
|
||||
import com.getui.push.v2.sdk.dto.req.message.ios.IosDTO;
|
||||
import com.getui.push.v2.sdk.dto.res.TaskIdDTO;
|
||||
import com.zbkj.common.config.GeTuiConfigProperties;
|
||||
import com.zbkj.common.constants.ImConstants;
|
||||
import com.zbkj.service.service.PushService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author 61962
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PushServiceImpl implements PushService {
|
||||
|
||||
private static PushApi pushApi;
|
||||
|
||||
@Autowired
|
||||
private GeTuiConfigProperties geTuiConfigProperties;
|
||||
|
||||
@PostConstruct
|
||||
public final void init() {
|
||||
// 设置httpClient最大连接数,当并发较大时建议调大此参数。或者启动参数加上 -Dhttp.maxConnections=200
|
||||
System.setProperty("http.maxConnections", "200");
|
||||
try {
|
||||
GtApiConfiguration apiConfiguration = new GtApiConfiguration();
|
||||
//填写应用配置
|
||||
apiConfiguration.setAppId(geTuiConfigProperties.getAppId());
|
||||
apiConfiguration.setAppKey(geTuiConfigProperties.getAppKey());
|
||||
apiConfiguration.setMasterSecret(geTuiConfigProperties.getMasterSecret());
|
||||
// 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId
|
||||
apiConfiguration.setDomain("https://restapi.getui.com/v2/");
|
||||
// 实例化ApiHelper对象,用于创建接口对象
|
||||
ApiHelper apiHelper = ApiHelper.build(apiConfiguration);
|
||||
// 创建对象,建议复用。目前有PushApi、StatisticApi、UserApi
|
||||
pushApi = apiHelper.creatApi(PushApi.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单的推送,单推
|
||||
*
|
||||
* @param title
|
||||
* @param body
|
||||
* @param cid 客户端生产的cid
|
||||
*/
|
||||
@Override
|
||||
public ApiResult<Map<String, Map<String, String>>> push(String title, String body, Long id, String cid, Integer type, String url) {
|
||||
//根据cid进行单推
|
||||
PushDTO<Audience> pushDTO = new PushDTO<Audience>();
|
||||
// 设置推送参数
|
||||
pushDTO.setRequestId(System.currentTimeMillis() + "");
|
||||
/**** 设置个推通道参数 *****/
|
||||
PushMessage pushMessage = new PushMessage();
|
||||
pushDTO.setPushMessage(pushMessage);
|
||||
GTNotification notification = new GTNotification();
|
||||
pushMessage.setNotification(notification);
|
||||
notification.setTitle(title);
|
||||
notification.setBody(body);
|
||||
notification.setPayload(body);
|
||||
notification.setClickType("payload");
|
||||
|
||||
|
||||
/*设置接收人信息*/
|
||||
Audience audience = new Audience();
|
||||
pushDTO.setAudience(audience);
|
||||
audience.addCid(cid);
|
||||
|
||||
PushChannel pushChannel = new PushChannel();
|
||||
|
||||
IosDTO iosDTO = new IosDTO();
|
||||
Aps aps = new Aps();
|
||||
aps.setSound("default");//设置苹果的声音
|
||||
aps.setContentAvailable(0);
|
||||
aps.setCategory("ACTIONABLE");
|
||||
Alert alert = new Alert();
|
||||
alert.setTitle(title);
|
||||
alert.setBody(title);
|
||||
aps.setAlert(alert);
|
||||
iosDTO.setAps(aps);
|
||||
// iosDTO.setAutoBadge("+1");//苹果角标
|
||||
iosDTO.setPayload(body);
|
||||
pushChannel.setIos(iosDTO);
|
||||
|
||||
|
||||
pushDTO.setPushChannel(pushChannel);
|
||||
/*设置接收人信息结束*/
|
||||
/**** 设置厂商相关参数,更多参数请查看文档或对象源码 ****/
|
||||
|
||||
// 进行cid单推
|
||||
ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushToSingleByCid(pushDTO);
|
||||
if (apiResult.isSuccess()) {
|
||||
// success
|
||||
log.info("cid:" + cid + " 消息推送成功:" + apiResult.getData());
|
||||
} else {
|
||||
// failed
|
||||
log.info("cid:" + cid + " 消息推送失败:" + "code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
|
||||
}
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单的推送,群推
|
||||
*
|
||||
* @param title
|
||||
* @param body
|
||||
*/
|
||||
@Override
|
||||
public ApiResult<TaskIdDTO> pushAll(String title, String body, Long id, Integer type, String url) {
|
||||
PushDTO<String> pushDTO = new PushDTO<String>();
|
||||
pushDTO.setRequestId(UUID.randomUUID().toString().substring(0, 16));
|
||||
pushDTO.setGroupName("g-name");
|
||||
|
||||
Settings settings = new Settings();
|
||||
settings.setTtl(3600000);
|
||||
|
||||
pushDTO.setSettings(settings);
|
||||
pushDTO.setAudience("all");
|
||||
|
||||
PushMessage pushMessage = new PushMessage();
|
||||
GTNotification notification = new GTNotification();
|
||||
notification.setTitle(title);
|
||||
notification.setBody(body);
|
||||
notification.setClickType(CommonEnum.ClickTypeEnum.TYPE_URL.type);
|
||||
notification.setUrl("https//:www.getui.com");
|
||||
pushMessage.setNotification(notification);
|
||||
pushDTO.setPushMessage(pushMessage);
|
||||
|
||||
// 群推
|
||||
ApiResult<TaskIdDTO> apiResult = pushApi.pushAll(pushDTO);
|
||||
if (apiResult.isSuccess()) {
|
||||
// success
|
||||
log.info(" 消息推送成功:" + apiResult.getData());
|
||||
} else {
|
||||
// failed
|
||||
log.info(" 消息推送失败:" + "code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
|
||||
}
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<Map<String, Map<String, String>>> uniPush(String title, String body, Long id, String cid, Integer type, String url, Integer category) {
|
||||
//根据cid进行单推
|
||||
PushDTO<Audience> pushDTO = new PushDTO<Audience>();
|
||||
// 设置推送参数,requestid需要每次变化唯一
|
||||
pushDTO.setRequestId(System.currentTimeMillis() + "");
|
||||
Settings settings = new Settings();
|
||||
pushDTO.setSettings(settings);
|
||||
//消息有效期,走厂商消息必须设置该值
|
||||
settings.setTtl(3600000);
|
||||
|
||||
//在线走个推通道时推送的消息体
|
||||
PushMessage pushMessage = new PushMessage();
|
||||
Map<String, Object> payload = new HashMap<>();
|
||||
payload.put("id", id);
|
||||
payload.put("type", type);
|
||||
payload.put("category", category);
|
||||
if (ImConstants.COMMON_TYPE_1.equals(type)) {
|
||||
payload.put("url", url);
|
||||
}
|
||||
JSONObject jsonPayload = new JSONObject();
|
||||
jsonPayload.putAll(payload);
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("title", title);
|
||||
map.put("content", body);
|
||||
map.put("payload", jsonPayload);
|
||||
JSONObject json = new JSONObject();
|
||||
json.putAll(map);
|
||||
//此格式的透传消息由 unipush 做了特殊处理,会自动展示通知栏。开发者也可自定义其它格式,在客户端自己处理。
|
||||
//pushMessage.setTransmission(" {title:\"标题\",content:\"内容\",payload:\"自定义数据\"}");
|
||||
//此格式的透传消息由 unipush 做了特殊处理,会自动展示通知栏。开发者也可自定义其它格式,在客户端自己处理。
|
||||
pushMessage.setTransmission(json.toString());
|
||||
pushDTO.setPushMessage(pushMessage);
|
||||
// 设置接收人信息
|
||||
Audience audience = new Audience();
|
||||
pushDTO.setAudience(audience);
|
||||
audience.addCid(cid);
|
||||
//设置离线推送时的消息体
|
||||
PushChannel pushChannel = new PushChannel();
|
||||
//安卓离线厂商通道推送的消息体
|
||||
AndroidDTO androidDTO = new AndroidDTO();
|
||||
Ups ups = new Ups();
|
||||
ThirdNotification thirdNotification = new ThirdNotification();
|
||||
ups.setNotification(thirdNotification);
|
||||
thirdNotification.setTitle(title);
|
||||
thirdNotification.setBody(body);
|
||||
thirdNotification.setClickType("intent");
|
||||
//注意:intent参数必须按下方文档(特殊参数说明)要求的固定格式传值,intent错误会导致客户端无法收到消息
|
||||
String intent = geTuiConfigProperties.getIntent();
|
||||
thirdNotification.setIntent(MessageFormat.format(intent, title, body));
|
||||
androidDTO.setUps(ups);
|
||||
pushChannel.setAndroid(androidDTO);
|
||||
|
||||
//ios离线apn通道推送的消息体
|
||||
Alert alert = new Alert();
|
||||
alert.setTitle(title);
|
||||
alert.setBody(body);
|
||||
Aps aps = new Aps();
|
||||
aps.setContentAvailable(0);
|
||||
aps.setSound(jsonPayload.toJSONString(0));
|
||||
aps.setAlert(alert);
|
||||
IosDTO iosDTO = new IosDTO();
|
||||
iosDTO.setAps(aps);
|
||||
iosDTO.setType("notify");
|
||||
pushChannel.setIos(iosDTO);
|
||||
|
||||
pushDTO.setPushChannel(pushChannel);
|
||||
/*设置接收人信息结束*/
|
||||
/**** 设置厂商相关参数,更多参数请查看文档或对象源码 ****/
|
||||
|
||||
// 进行cid单推
|
||||
ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushToSingleByCid(pushDTO);
|
||||
if (apiResult.isSuccess()) {
|
||||
// success
|
||||
log.info("cid:" + cid + " 消息推送成功uni:" + apiResult.getData());
|
||||
} else {
|
||||
// failed
|
||||
log.info("cid:" + cid + " 消息推送失败uni:" + "code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
|
||||
}
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<TaskIdDTO> uniPushAll(String title, String body, Long id, Integer type, String url, Integer category) {
|
||||
//根据cid进行单推
|
||||
PushDTO<String> pushDTO = new PushDTO<String>();
|
||||
// 设置推送参数,requestid需要每次变化唯一
|
||||
pushDTO.setRequestId(System.currentTimeMillis() + "");
|
||||
Settings settings = new Settings();
|
||||
pushDTO.setSettings(settings);
|
||||
//消息有效期,走厂商消息必须设置该值
|
||||
settings.setTtl(3600000);
|
||||
|
||||
//在线走个推通道时推送的消息体
|
||||
PushMessage pushMessage = new PushMessage();
|
||||
//此格式的透传消息由 unipush 做了特殊处理,会自动展示通知栏。开发者也可自定义其它格式,在客户端自己处理。
|
||||
//pushMessage.setTransmission(" {title:\"标题\",content:\"内容\",payload:\"自定义数据\"}");
|
||||
Map<String, Object> payload = new HashMap<>();
|
||||
payload.put("id", id);
|
||||
payload.put("type", type);
|
||||
payload.put("category", category);
|
||||
if (ImConstants.COMMON_TYPE_1.equals(type)) {
|
||||
payload.put("url", url);
|
||||
}
|
||||
JSONObject jsonPayload = new JSONObject();
|
||||
jsonPayload.putAll(payload);
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("title", title);
|
||||
map.put("content", body);
|
||||
map.put("payload", jsonPayload);
|
||||
JSONObject json = new JSONObject();
|
||||
json.putAll(map);
|
||||
//此格式的透传消息由 unipush 做了特殊处理,会自动展示通知栏。开发者也可自定义其它格式,在客户端自己处理。
|
||||
pushMessage.setTransmission(json.toString());
|
||||
pushDTO.setPushMessage(pushMessage);
|
||||
// 设置接收人信息
|
||||
pushDTO.setAudience("all");
|
||||
//设置离线推送时的消息体
|
||||
PushChannel pushChannel = new PushChannel();
|
||||
//安卓离线厂商通道推送的消息体
|
||||
AndroidDTO androidDTO = new AndroidDTO();
|
||||
Ups ups = new Ups();
|
||||
ThirdNotification thirdNotification = new ThirdNotification();
|
||||
ups.setNotification(thirdNotification);
|
||||
thirdNotification.setTitle(title);
|
||||
thirdNotification.setBody(body);
|
||||
thirdNotification.setClickType("intent");
|
||||
//注意:intent参数必须按下方文档(特殊参数说明)要求的固定格式传值,intent错误会导致客户端无法收到消息
|
||||
String intent = geTuiConfigProperties.getIntent();
|
||||
thirdNotification.setIntent(MessageFormat.format(intent, title, body));
|
||||
androidDTO.setUps(ups);
|
||||
pushChannel.setAndroid(androidDTO);
|
||||
|
||||
//ios离线apn通道推送的消息体
|
||||
Alert alert = new Alert();
|
||||
alert.setTitle(title);
|
||||
alert.setBody(body);
|
||||
Aps aps = new Aps();
|
||||
aps.setContentAvailable(0);
|
||||
aps.setSound(jsonPayload.toJSONString(0));
|
||||
aps.setAlert(alert);
|
||||
IosDTO iosDTO = new IosDTO();
|
||||
iosDTO.setAps(aps);
|
||||
iosDTO.setType("notify");
|
||||
pushChannel.setIos(iosDTO);
|
||||
|
||||
pushDTO.setPushChannel(pushChannel);
|
||||
|
||||
// 群推
|
||||
ApiResult<TaskIdDTO> apiResult = pushApi.pushAll(pushDTO);
|
||||
if (apiResult.isSuccess()) {
|
||||
// success
|
||||
log.info(" 消息推送成功uni:" + apiResult.getData());
|
||||
} else {
|
||||
// failed
|
||||
log.info("title:" + title + ";body:" + body);
|
||||
log.info(" 消息推送失败uni:" + "code:" + apiResult.getCode() + ", msg: " + apiResult.getMsg());
|
||||
}
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user