新增日志及通道修改
This commit is contained in:
parent
e6d54fcc85
commit
25f59c124b
|
|
@ -147,6 +147,7 @@ public class AliyunPushApi {
|
|||
|
||||
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) {
|
||||
|
|
@ -156,6 +157,7 @@ public class AliyunPushApi {
|
|||
|
||||
public static ApiHelper apiHelper = null;
|
||||
public static PushApi pushApi = null;
|
||||
|
||||
static {
|
||||
System.setProperty("http.maxConnections", "200");
|
||||
GtApiConfiguration apiConfiguration = new GtApiConfiguration();
|
||||
|
|
@ -205,6 +207,8 @@ public class AliyunPushApi {
|
|||
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);
|
||||
|
|
@ -214,12 +218,57 @@ public class AliyunPushApi {
|
|||
audience.addCid(aliyunDeviceInfo.getAliyunDeviceId());
|
||||
// 进行cid单推
|
||||
ApiResult<Map<String, Map<String, String>>> apiResult = pushApi.pushToSingleByCid(pushDTO);
|
||||
log.info("gtPush request : " + aliyunDeviceInfo.getAliyunDeviceId() + " , response : " + JSONObject.toJSONString(apiResult));
|
||||
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) {
|
||||
|
|
@ -300,6 +349,7 @@ public class AliyunPushApi {
|
|||
|
||||
/**
|
||||
* 随机生成字母与数字组合
|
||||
*
|
||||
* @param length
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -350,6 +400,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'};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue