Compare commits

...

10 Commits

Author SHA1 Message Date
yan.y 493f56593f 0.0温度忽略 2026-03-26 15:08:53 +08:00
yan.y 44b3eb14f1 更新0.0摄氏度推送限制 2026-02-07 21:41:05 +08:00
yan.y 25f59c124b 新增日志及通道修改 2025-04-07 17:52:38 +08:00
yan.y e6d54fcc85 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	src/main/java/com/ifish7/mq/push/AliyunPushApi.java
2025-02-11 14:05:25 +08:00
yan.y 734367fcfc 版本更新 2025-02-11 14:04:56 +08:00
yiyan 353641ce6a update 2025-02-10 21:27:57 +08:00
yan.y 441439d492 update 2025-01-10 20:29:06 +08:00
yan.y 6d2a37365e 新增参数 2024-01-05 14:00:38 +08:00
易焱 4dd470767a 阿里云推送优化 2020-01-05 19:56:04 +08:00
易焱 c49dc9b3e5 屏蔽网易云信消息推送 2019-09-25 00:00:23 +08:00
7 changed files with 311 additions and 84 deletions

12
pom.xml
View File

@ -233,6 +233,18 @@
<version>${fastjson.version}</version>
</dependency>
<dependency>
<groupId>com.getui.push</groupId>
<artifactId>restful-sdk</artifactId>
<version>1.0.6.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1.1-jre</version>
</dependency>
</dependencies>
<build>

View File

@ -29,6 +29,11 @@ public class TblAliyunDeviceInfo {
*/
private Integer userId;
/**
* 类型 0默认 1个推
*/
private Integer type;
/**
* 手机类型
*/

View File

@ -46,7 +46,7 @@ public class TblPushList {
private String neteaseStatus = "1";
private Integer reportId;
private String reportId;
private Integer number1;

View File

@ -9,24 +9,36 @@ import com.aliyuncs.push.model.v20160801.PushRequest;
import com.aliyuncs.push.model.v20160801.PushResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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 com.getui.push.v2.sdk.dto.req.message.android.ThirdNotification;
import com.getui.push.v2.sdk.dto.req.message.android.Ups;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.ifish7.mq.business.user.entity.TblAliyunDeviceInfo;
import com.ifish7.mq.business.user.entity.TblPushList;
import com.ifish7.mq.business.user.service.ITblAliyunDeviceInfoService;
import com.ifish7.mq.business.user.service.ITblPushListService;
import lombok.extern.log4j.Log4j;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import java.security.MessageDigest;
import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
/**
* @author: yan.y
@ -36,9 +48,10 @@ import java.util.*;
@Log4j
public class AliyunPushApi {
private DefaultAcsClient client;
private final DefaultAcsClient client;
public AliyunPushApi(String regionId,String accessKeyId,String accessKeySecret){
public AliyunPushApi(String regionId, String accessKeyId, String accessKeySecret) {
client = new DefaultAcsClient(DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret));
}
@ -53,6 +66,15 @@ public class AliyunPushApi {
@Value("${ios_app_key}")
private String iosAppKey;
@Value("${gtAppId}")
private String gtAppId;
@Value("${gtAppKey}")
private String gtAppKey;
@Value("${gtMasterSecret}")
private String gtMasterSecret;
@Autowired
private PushRequest pushRequest;
@ -65,75 +87,259 @@ public class AliyunPushApi {
@Autowired
private ITblAliyunDeviceInfoService aliyunDeviceInfoService;
public void advancedPush(TblPushList pushList){
private static LoadingCache<String, Long> limitPushCaches = CacheBuilder.newBuilder()
.maximumSize(100000)
.expireAfterWrite(24, TimeUnit.HOURS)
.build(new CacheLoader<String, Long>() {
@Override
public Long load(String s) {
return 0L;
}
});
public void advancedPush(TblPushList pushList) {
//温度告警 0.0° 屏蔽0.0
if (pushList.getPushType().equals("wendu_warn") && pushList.getPushContext().indexOf("达到0.0") > 0) {
log.info("0.0告警忽略 : " + JSONObject.toJSONString(pushList));
return;
// try {
// Long l = limitPushCaches.get(pushList.getDeviceId().toString());
// if (l != null && l > 0) {
// log.info("24小时内已推送当前消息忽略 : " + JSONObject.toJSONString(pushList));
// return;
// }
// } catch (Exception e) {
// log.error("check error", e);
// }
// limitPushCaches.put(pushList.getDeviceId().toString(), System.currentTimeMillis());
}
//根据Target来设定多个值使用逗号分隔
//此处应该查询出用户所对应的deviceId
// String deviceIds = getUserDevices(String.valueOf(pushList.getUserId()));
//查询所有
LambdaQueryWrapper<TblAliyunDeviceInfo> allQuary = new QueryWrapper<TblAliyunDeviceInfo>().lambda().eq(TblAliyunDeviceInfo::getUserId, pushList.getUserId());
if ("IOS".equals(pushList.getPhoneType().toUpperCase())) {
allQuary.eq(TblAliyunDeviceInfo::getPhoneType,"iOS");
} else if("ANDROID".equals(pushList.getPhoneType().toUpperCase())) {
allQuary.eq(TblAliyunDeviceInfo::getPhoneType,"ANDROID");
if ("IOS".equalsIgnoreCase(pushList.getPhoneType())) {
allQuary.eq(TblAliyunDeviceInfo::getPhoneType, "iOS");
} else if ("ANDROID".equalsIgnoreCase(pushList.getPhoneType())) {
allQuary.eq(TblAliyunDeviceInfo::getPhoneType, "ANDROID");
}
List<TblAliyunDeviceInfo> pushUserDevices = aliyunDeviceInfoService.list(allQuary);
pushUserDevices.forEach(aliyunDeviceInfo -> {
if ("iOS".equals(aliyunDeviceInfo.getPhoneType())) {
pushRequest.setAppKey(Long.parseLong(iosAppKey));
if (aliyunDeviceInfo.getType() == 1) {
gtPush(pushList, aliyunDeviceInfo);
} else {
pushRequest.setAppKey(Long.parseLong(androidAppKey));
}
//推送目标
//DEVICE:根据设备推送
//ACCOUNT:根据账号推送
//ALIAS:根据别名推送
//TAG:根据标签推送
//ALL:推送给全部设备
pushRequest.setTarget(TARGET_TYPE);
//响应数据
pushRequest.setAcceptFormat(FormatType.JSON);
pushRequest.setTargetValue(aliyunDeviceInfo.getAliyunDeviceId());
//推送类型
pushRequest.setPushType(PUSH_TYPE);
//推送设备类型
pushRequest.setDeviceType(aliyunDeviceInfo.getPhoneType());
// 消息的标题
pushRequest.setTitle(pushList.getPushTitle());
// 消息的内容
pushRequest.setBody(pushList.getPushContext());
// 离线消息是否保存,若保存, 在推送时候用户即使不在线下一次上线则会收到
pushRequest.setStoreOffline(true);
//android通知设置
pushRequest.setAndroidOpenType("APPLICATION");
pushRequest.setAndroidNotifyType("BOTH");
pushRequest.setAndroidPopupActivity("PopupPushActivity");
pushRequest.setAndroidPopupTitle(pushList.getPushTitle());
pushRequest.setAndroidPopupBody(pushList.getPushContext());
pushRequest.setAndroidRemind(true);
try {
PushResponse response = client.getAcsResponse(pushRequest);
pushList.setReportId(Integer.parseInt(response.getMessageId()));
pushList.setDeviceId((pushList.getDeviceId() == null || pushList.getDeviceId() == 0)? null : pushList.getDeviceId());
} catch (ClientException e) {
log.error(e.getMessage(),e);
aliyunPush(pushList, aliyunDeviceInfo);
}
});
//未读
pushList.setIsRead(1);
pushListService.save(pushList);
sendMsg(String.valueOf(pushList.getUserId()),pushList.getPushContext());
//sendMsg(String.valueOf(pushList.getUserId()),pushList.getPushContext());
}
private void aliyunPush(TblPushList pushList, TblAliyunDeviceInfo aliyunDeviceInfo) {
if ("iOS".equals(aliyunDeviceInfo.getPhoneType())) {
pushRequest.setAppKey(Long.parseLong(iosAppKey));
} else {
pushRequest.setAppKey(Long.parseLong(androidAppKey));
pushRequest.setAndroidNotificationChannel("1");
}
//推送目标
//DEVICE:根据设备推送
//ACCOUNT:根据账号推送
//ALIAS:根据别名推送
//TAG:根据标签推送
//ALL:推送给全部设备
pushRequest.setTarget(TARGET_TYPE);
//响应数据
pushRequest.setAcceptFormat(FormatType.JSON);
pushRequest.setTargetValue(aliyunDeviceInfo.getAliyunDeviceId());
//推送类型
pushRequest.setPushType(PUSH_TYPE);
//推送设备类型
pushRequest.setDeviceType(aliyunDeviceInfo.getPhoneType());
// 消息的标题
pushRequest.setTitle(pushList.getPushTitle());
// 消息的内容
pushRequest.setBody(pushList.getPushContext());
// 离线消息是否保存,若保存, 在推送时候用户即使不在线下一次上线则会收到
pushRequest.setStoreOffline(true);
//android通知设置
pushRequest.setAndroidOpenType("APPLICATION");
pushRequest.setAndroidNotifyType("BOTH");
pushRequest.setAndroidPopupActivity("PopupPushActivity");
pushRequest.setAndroidPopupTitle(pushList.getPushTitle());
pushRequest.setAndroidPopupBody(pushList.getPushContext());
pushRequest.setAndroidRemind(true);
try {
PushResponse response = client.getAcsResponse(pushRequest);
log.info("阿里云推送\t" + aliyunDeviceInfo.getUserId() + "\t" + aliyunDeviceInfo.getAliyunDeviceId() + "\t" + JSONObject.toJSONString(response));
pushList.setReportId(response.getMessageId());
pushList.setDeviceId((pushList.getDeviceId() == null || pushList.getDeviceId() == 0) ? null : pushList.getDeviceId());
} catch (ClientException e) {
log.error(e.getMessage(), e);
}
}
public static ApiHelper apiHelper = null;
public static PushApi pushApi = null;
static {
System.setProperty("http.maxConnections", "200");
GtApiConfiguration apiConfiguration = new GtApiConfiguration();
//填写应用配置
apiConfiguration.setAppId("C2ZpsHzexi5UKuUKyW0Ig");
apiConfiguration.setAppKey("099ng3u5ud5pVGqsH0GlK");
apiConfiguration.setMasterSecret("w3yLh3Ng4j5JYqGYH7C7o9");
// 接口调用前缀请查看文档: 接口调用规范 -> 接口前缀
apiConfiguration.setDomain("https://restapi.getui.com/v2/");
apiHelper = ApiHelper.build(apiConfiguration);
pushApi = apiHelper.creatApi(PushApi.class);
}
private void gtPush(TblPushList pushList, TblAliyunDeviceInfo aliyunDeviceInfo) {
//根据cid进行单推
PushDTO<Audience> pushDTO = new PushDTO<>();
// 设置推送参数
pushDTO.setRequestId(System.currentTimeMillis() + "");
PushMessage pushMessage = new PushMessage();
pushDTO.setPushMessage(pushMessage);
GTNotification notification = new GTNotification();
pushMessage.setNotification(notification);
notification.setTitle(pushList.getPushTitle());
notification.setBody(pushList.getPushContext());
notification.setClickType("startapp");
PushChannel pushChannel = new PushChannel();
pushDTO.setPushChannel(pushChannel);
/*配置安卓厂商参数*/
AndroidDTO androidDTO = new AndroidDTO();
Ups ups = new Ups();
ThirdNotification thirdNotification = new ThirdNotification();
thirdNotification.setTitle(pushList.getPushTitle());
thirdNotification.setBody(pushList.getPushContext());
thirdNotification.setClickType("startapp");
ups.setNotification(thirdNotification);
Map<String, Map<String, Object>> options = new HashMap<>();
Map<String, Object> HO = new HashMap<>();
HO.put("/android/notification/importance", "NORMAL");
options.put("HO", HO);
Map<String, Object> HW = new HashMap<>();
HW.put("/message/android/category", "WORK");
options.put("HW", HW);
Map<String, Object> XM = new HashMap<>();
XM.put("/extra.channel_id", "131247");
options.put("XM", XM);
Map<String, Object> OP = new HashMap<>();
OP.put("/channel_id", "push_oplus_category_content");
OP.put("/category", "DEVICE_REMINDER");
OP.put("/notify_level", 2);
options.put("OP", OP);
ups.setOptions(options);
androidDTO.setUps(ups);
pushChannel.setAndroid(androidDTO);
Audience audience = new Audience();
pushDTO.setAudience(audience);
audience.addCid(aliyunDeviceInfo.getAliyunDeviceId());
// 进行cid单推
ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushToSingleByCid(pushDTO);
log.info("个推推送\t" + "\t" + aliyunDeviceInfo.getUserId() + aliyunDeviceInfo.getAliyunDeviceId() + "\t" + JSONObject.toJSONString(apiResult));
}
public static void main(String[] args) {
//根据cid进行单推
PushDTO<Audience> pushDTO = new PushDTO<>();
// 设置推送参数
pushDTO.setRequestId(System.currentTimeMillis() + "");
PushMessage pushMessage = new PushMessage();
pushDTO.setPushMessage(pushMessage);
GTNotification notification = new GTNotification();
pushMessage.setNotification(notification);
notification.setTitle("测试");
notification.setBody("测试");
notification.setClickType("startapp");
PushChannel pushChannel = new PushChannel();
pushDTO.setPushChannel(pushChannel);
/*配置安卓厂商参数*/
AndroidDTO androidDTO = new AndroidDTO();
Ups ups = new Ups();
ThirdNotification thirdNotification = new ThirdNotification();
thirdNotification.setTitle("测试");
thirdNotification.setBody("测试");
thirdNotification.setClickType("startapp");
ups.setNotification(thirdNotification);
Map<String, Map<String, Object>> options = new HashMap<>();
Map<String, Object> HO = new HashMap<>();
HO.put("/android/notification/importance", "NORMAL");
options.put("HO", HO);
Map<String, Object> HW = new HashMap<>();
HW.put("/message/android/category", "WORK");
options.put("HW", HW);
Map<String, Object> XM = new HashMap<>();
XM.put("/extra.channel_id", "131247");
options.put("XM", XM);
Map<String, Object> OP = new HashMap<>();
OP.put("/channel_id", "push_oplus_category_service");
OP.put("/category", "DEVICE_REMINDER");
OP.put("/notify_level", 2);
options.put("OP", OP);
ups.setOptions(options);
androidDTO.setUps(ups);
pushChannel.setAndroid(androidDTO);
Audience audience = new Audience();
pushDTO.setAudience(audience);
audience.addCid("0de17157d2fbfdc1cc53b705f810ce44");
// 进行cid单推
ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushToSingleByCid(pushDTO);
log.info("gtPush request : 0de17157d2fbfdc1cc53b705f810ce44 , response : " + JSONObject.toJSONString(apiResult));
}
/*public static void main(String[] args) {
//8cfcfe16d96ef9345391de475bb5297d
SingleMessage singleMessage = new SingleMessage();
Style0 style = new Style0();
// 设置通知栏标题与内容
style.setTitle("测试推送-11111");
style.setText("测试推送-11111");
// 设置通知是否响铃震动或者可清除
style.setRing(true);
style.setVibrate(true);
style.setClearable(true);
NotificationTemplate notificationTemplate = new NotificationTemplate();
notificationTemplate.setAppId("C2ZpsHzexi5UKuUKyW0Ig");
notificationTemplate.setAppkey("099ng3u5ud5pVGqsH0GlK");
notificationTemplate.setStyle(style);
singleMessage.setData(notificationTemplate);
singleMessage.setOffline(true);
singleMessage.setOfflineExpireTime(72 * 3600000L);
Target target = new Target();
target.setAppId("C2ZpsHzexi5UKuUKyW0Ig");
target.setClientId("fc8c87fa41da480fb769fbdae92c4cd2");
IGtPush iGtPush = new IGtPush(HOST_HTTPS, "099ng3u5ud5pVGqsH0GlK", "w3yLh3Ng4j5JYqGYH7C7o9");
IPushResult pushResult = iGtPush.pushMessageToSingle(singleMessage, target);
System.out.println(JSONObject.toJSONString(pushResult));
Map<String, Object> response = pushResult.getResponse();
System.out.println(response);
}*/
/**
* 发送普通消息
* 发送普通消息 (已废弃 网易云信)
* @param userId
* @param msg
* @return
*/
/*@Deprecated
public JSONObject sendMsg(String userId, String msg){
String appSecret = "e62f6c247b46";
String appKey = "87b0e3315dfc2df08060bcb54246da68";
@ -171,10 +377,11 @@ public class AliyunPushApi {
log.error("refreshToken error message:{}",e);
}
return null;
}
}*/
/**
* 随机生成字母与数字组合
*
* @param length
* @return
*/
@ -225,6 +432,7 @@ public class AliyunPushApi {
}
return buf.toString();
}
private static final char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
private static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
}

View File

@ -1,20 +1,20 @@
log4j.rootLogger=DEBUG,Console,File
#\u5B9A\u4E49\u65E5\u5FD7\u8F93\u51FA\u76EE\u7684\u5730\u4E3A\u63A7\u5236\u53F0
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
#\u53EF\u4EE5\u7075\u6D3B\u5730\u6307\u5B9A\u65E5\u5FD7\u8F93\u51FA\u683C\u5F0F\uFF0C\u4E0B\u9762\u4E00\u884C\u662F\u6307\u5B9A\u5177\u4F53\u7684\u683C\u5F0F
log4j.appender.Console.layout = org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[ifishMQ][%c] - %m%n
#\u6587\u4EF6\u5927\u5C0F\u5230\u8FBE\u6307\u5B9A\u5C3A\u5BF8\u7684\u65F6\u5019\u4EA7\u751F\u4E00\u4E2A\u65B0\u7684\u6587\u4EF6
log4j.appender.File = org.apache.log4j.RollingFileAppender
log4j.rootLogger=DEBUG,Console,File
#\u5B9A\u4E49\u65E5\u5FD7\u8F93\u51FA\u76EE\u7684\u5730\u4E3A\u63A7\u5236\u53F0
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
#\u53EF\u4EE5\u7075\u6D3B\u5730\u6307\u5B9A\u65E5\u5FD7\u8F93\u51FA\u683C\u5F0F\uFF0C\u4E0B\u9762\u4E00\u884C\u662F\u6307\u5B9A\u5177\u4F53\u7684\u683C\u5F0F
log4j.appender.Console.layout = org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[ifishMQ]][%p] [%d{yyyy-MM-dd HH\:mm\:ss}] [%c]%m%n
#\u6587\u4EF6\u5927\u5C0F\u5230\u8FBE\u6307\u5B9A\u5C3A\u5BF8\u7684\u65F6\u5019\u4EA7\u751F\u4E00\u4E2A\u65B0\u7684\u6587\u4EF6
log4j.appender.File = org.apache.log4j.RollingFileAppender
#\u6307\u5B9A\u8F93\u51FA\u76EE\u5F55
log4j.appender.File.File = logs/ifishMQ.log
log4j.appender.File.File = logs/ifishMQ.log
#\u5B9A\u4E49\u6587\u4EF6\u6700\u5927\u5927\u5C0F
log4j.appender.File.MaxFileSize = 100
#\u8F93\u51FA\u6240\u4EE5\u65E5\u5FD7\uFF0C\u5982\u679C\u6362\u6210DEBUG\u8868\u793A\u8F93\u51FADEBUG\u4EE5\u4E0A\u7EA7\u522B\u65E5\u5FD7
log4j.appender.File.Threshold = ALL
log4j.appender.File.layout = org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern =[ifishMQ][%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%c]%m%n
#\u8F93\u51FA\u6240\u4EE5\u65E5\u5FD7\uFF0C\u5982\u679C\u6362\u6210DEBUG\u8868\u793A\u8F93\u51FADEBUG\u4EE5\u4E0A\u7EA7\u522B\u65E5\u5FD7
log4j.appender.File.Threshold = ALL
log4j.appender.File.layout = org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern =[ifishMQ]][%p] [%d{yyyy-MM-dd HH\:mm\:ss}] [%c]%m%n
log4j.logger.org.springframework=INFO
log4j.logger.org.apache.activemq=INFO

View File

@ -24,4 +24,6 @@ version = 2016-08-01
# \u53D1\u9001\u7684tag, tag\u8868\u8FBE\u5F0F\u53C2\u8003\u6587\u6863:https://help.aliyun.com/document_detail/48055.html?
#tag =
#tagExpression =
gtAppId=C2ZpsHzexi5UKuUKyW0Ig
gtAppKey=099ng3u5ud5pVGqsH0GlK
gtMasterSecret=w3yLh3Ng4j5JYqGYH7C7o9

View File

@ -28,7 +28,7 @@ public class AliyunPushApiTest {
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAIfZaosFH5IWlD", "dvlE8eFii31BcGb8HzkGz3eSaJ6Y94");
DefaultAcsClient client = new DefaultAcsClient(profile);
PushRequest pushRequest = new PushRequest();
pushRequest.setAppKey(26023230l);
pushRequest.setAppKey(26007228L);
pushRequest.setSysProtocol(ProtocolType.HTTPS);
pushRequest.setSysMethod(MethodType.POST);
pushRequest.setStoreOffline(true);
@ -46,15 +46,15 @@ public class AliyunPushApiTest {
pushRequest.setAcceptFormat(FormatType.JSON);
//根据Target来设定多个值使用逗号分隔
//此处应该查询出用户所对应的deviceId
pushRequest.setTargetValue("8b42082f3fd9447f9c662804f10ab142");
pushRequest.setTargetValue("cc7a8e2e157040e88416bf2192320b24");
//推送类型
pushRequest.setPushType("NOTICE");
//推送设备类型
pushRequest.setDeviceType("ANDROID");
pushRequest.setDeviceType("ALL");
// 消息的标题
pushRequest.setTitle("小米推送测试");
pushRequest.setTitle("推送测试");
// 消息的内容
pushRequest.setBody("小米推送测试");
pushRequest.setBody("推送测试");
// 推送配置: Android
pushRequest.setAndroidNotifyType("BOTH");//通知的提醒方式 "VIBRATE" : 震动 "SOUND" : 声音 "BOTH" : 声音和震动 NONE : 静音
@ -64,8 +64,8 @@ public class AliyunPushApiTest {
pushRequest.setAndroidOpenType("APPLICATION");
pushRequest.setAndroidNotifyType("BOTH");
pushRequest.setAndroidPopupActivity("PopupPushActivity");
pushRequest.setAndroidPopupTitle("小米推送测试");
pushRequest.setAndroidPopupBody("小米推送测试");
pushRequest.setAndroidPopupTitle("推送测试");
pushRequest.setAndroidPopupBody("推送测试");
pushRequest.setAndroidRemind(true);
// 指定notificaitonchannel id
// pushRequest.setAndroidNotificationChannel("1");
@ -77,11 +77,11 @@ public class AliyunPushApiTest {
}
}
@Test
/*@Test
public void testSendMsg() {
AliyunPushApi pushApi = new AliyunPushApi("","","");
JSONObject jsonObject = pushApi.sendMsg("20731", "网易云信推送测试!");
System.out.println(jsonObject.toJSONString());
}
}*/
}