|
|
|
|
@ -9,36 +9,24 @@ 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.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author: yan.y
|
|
|
|
|
@ -48,10 +36,9 @@ import java.util.concurrent.TimeUnit;
|
|
|
|
|
@Log4j
|
|
|
|
|
public class AliyunPushApi {
|
|
|
|
|
|
|
|
|
|
private final DefaultAcsClient client;
|
|
|
|
|
private 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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -66,15 +53,6 @@ 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;
|
|
|
|
|
|
|
|
|
|
@ -87,259 +65,75 @@ public class AliyunPushApi {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ITblAliyunDeviceInfoService aliyunDeviceInfoService;
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
public void advancedPush(TblPushList pushList){
|
|
|
|
|
|
|
|
|
|
//根据Target来设定,多个值使用逗号分隔
|
|
|
|
|
//此处应该查询出用户所对应的deviceId ★★★★★
|
|
|
|
|
// String deviceIds = getUserDevices(String.valueOf(pushList.getUserId()));
|
|
|
|
|
//查询所有
|
|
|
|
|
LambdaQueryWrapper<TblAliyunDeviceInfo> allQuary = new QueryWrapper<TblAliyunDeviceInfo>().lambda().eq(TblAliyunDeviceInfo::getUserId, pushList.getUserId());
|
|
|
|
|
if ("IOS".equalsIgnoreCase(pushList.getPhoneType())) {
|
|
|
|
|
allQuary.eq(TblAliyunDeviceInfo::getPhoneType, "iOS");
|
|
|
|
|
} else if ("ANDROID".equalsIgnoreCase(pushList.getPhoneType())) {
|
|
|
|
|
allQuary.eq(TblAliyunDeviceInfo::getPhoneType, "ANDROID");
|
|
|
|
|
if ("IOS".equals(pushList.getPhoneType().toUpperCase())) {
|
|
|
|
|
allQuary.eq(TblAliyunDeviceInfo::getPhoneType,"iOS");
|
|
|
|
|
} else if("ANDROID".equals(pushList.getPhoneType().toUpperCase())) {
|
|
|
|
|
allQuary.eq(TblAliyunDeviceInfo::getPhoneType,"ANDROID");
|
|
|
|
|
}
|
|
|
|
|
List<TblAliyunDeviceInfo> pushUserDevices = aliyunDeviceInfoService.list(allQuary);
|
|
|
|
|
pushUserDevices.forEach(aliyunDeviceInfo -> {
|
|
|
|
|
if (aliyunDeviceInfo.getType() == 1) {
|
|
|
|
|
gtPush(pushList, aliyunDeviceInfo);
|
|
|
|
|
if ("iOS".equals(aliyunDeviceInfo.getPhoneType())) {
|
|
|
|
|
pushRequest.setAppKey(Long.parseLong(iosAppKey));
|
|
|
|
|
} else {
|
|
|
|
|
aliyunPush(pushList, aliyunDeviceInfo);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
//未读
|
|
|
|
|
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";
|
|
|
|
|
@ -377,11 +171,10 @@ public class AliyunPushApi {
|
|
|
|
|
log.error("refreshToken error message:{}",e);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 随机生成字母与数字组合
|
|
|
|
|
*
|
|
|
|
|
* @param length
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@ -432,7 +225,6 @@ 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' };
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|