105 lines
4.3 KiB
Java
105 lines
4.3 KiB
Java
package com.zhgd.xmgl.util;
|
||
|
||
//import com.gexin.rp.sdk.base.IPushResult;
|
||
//import com.gexin.rp.sdk.base.impl.SingleMessage;
|
||
//import com.gexin.rp.sdk.base.impl.Target;
|
||
//import com.gexin.rp.sdk.base.payload.APNPayload;
|
||
//import com.gexin.rp.sdk.base.payload.MultiMedia;
|
||
//import com.gexin.rp.sdk.exceptions.RequestException;
|
||
//import com.gexin.rp.sdk.http.Constants;
|
||
//import com.gexin.rp.sdk.http.IGtPush;
|
||
//import com.gexin.rp.sdk.template.NotificationTemplate;
|
||
|
||
/**
|
||
* @program: wisdomSite
|
||
* @description: 个推消息推送
|
||
* @author: Mr.Peng
|
||
* @create: 2020-11-13 14:12
|
||
**/
|
||
|
||
public class PushUtil {
|
||
|
||
private static String appId = "";
|
||
private static String appKey = "";
|
||
private static String masterSecret = "";
|
||
|
||
static String host = "http://api.getui.com/apiex.htm";
|
||
|
||
// public static void push(String alias,String remark){
|
||
// // 设置后,根据别名推送,会返回每个cid的推送结果
|
||
// System.setProperty(Constants.GEXIN_PUSH_SINGLE_ALIAS_DETAIL, "true");
|
||
// IGtPush push = new IGtPush(host, appKey, masterSecret);
|
||
// NotificationTemplate template = getNotificationTemplate(remark);
|
||
// SingleMessage message = new SingleMessage();
|
||
// message.setOffline(true);
|
||
// // 离线有效时间,单位为毫秒
|
||
// message.setOfflineExpireTime(24 * 3600 * 1000);
|
||
// message.setData(template);
|
||
// // 可选,1为wifi,0为不限制网络环境。根据手机处于的网络情况,决定是否下发
|
||
// message.setPushNetWorkType(0);
|
||
// // 厂商通道下发策略
|
||
// message.setStrategyJson("{\"default\":4,\"ios\":4,\"st\":4}");
|
||
// Target target = new Target();
|
||
// target.setAppId(appId);
|
||
// target.setAlias(alias);
|
||
// IPushResult ret = null;
|
||
// try {
|
||
// ret = push.pushMessageToSingle(message, target);
|
||
// } catch (RequestException e) {
|
||
// log.error("error:",e);
|
||
// ret = push.pushMessageToSingle(message, target, e.getRequestId());
|
||
// }
|
||
// if (ret != null) {
|
||
// log.info(ret.getResponse().toString());
|
||
// } else {
|
||
// log.info("服务器响应异常");
|
||
// }
|
||
// }
|
||
//
|
||
// public static NotificationTemplate getNotificationTemplate(String remark) {
|
||
// NotificationTemplate template = new NotificationTemplate();
|
||
// // 设置APPID与APPKEY
|
||
// template.setAppId(appId);
|
||
// template.setAppkey(appKey);
|
||
//
|
||
// template.setTransmissionType(1); // 透传消息接受方式设置,1:立即启动APP,2:客户端收到消息后需要自行处理
|
||
// template.setTransmissionContent(remark);
|
||
//
|
||
// //template.setAPNInfo(getAPNPayload()); //详见【推送模板说明】iOS通知样式设置
|
||
// return template;
|
||
// }
|
||
//
|
||
// private static APNPayload getAPNPayload() {
|
||
// APNPayload payload = new APNPayload();
|
||
// //在已有数字基础上加1显示,设置为-1时,在已有数字上减1显示,设置为数字时,显示指定数字
|
||
// payload.setAutoBadge("+1");
|
||
// payload.setContentAvailable(1);
|
||
// //ios 12.0 以上可以使用 Dictionary 类型的 sound
|
||
// payload.setSound("default");
|
||
// payload.setCategory("$由客户端定义");
|
||
// payload.addCustomMsg("由客户自定义消息key", "由客户自定义消息value");
|
||
// //简单模式APNPayload.SimpleMsg
|
||
// // payload.setAlertMsg(new APNPayload.SimpleAlertMsg("hello"));
|
||
// // payload.setAlertMsg(getDictionaryAlertMsg()); //字典模式使用APNPayload.DictionaryAlertMsg
|
||
//
|
||
// //设置语音播报类型,int类型,0.不可用 1.播放body 2.播放自定义文本
|
||
// payload.setVoicePlayType(2);
|
||
// //设置语音播报内容,String类型,非必须参数,用户自定义播放内容,仅在voicePlayMessage=2时生效
|
||
// //注:当"定义类型"=2, "定义内容"为空时则忽略不播放
|
||
// payload.setVoicePlayMessage("定义内容");
|
||
//
|
||
// // 添加多媒体资源
|
||
// payload.addMultiMedia(new MultiMedia()
|
||
// .setResType(MultiMedia.MediaType.pic)
|
||
// .setResUrl("资源文件地址")
|
||
// .setOnlyWifi(true));
|
||
//
|
||
// return payload;
|
||
// }
|
||
|
||
public static void main(String[] args) {
|
||
|
||
}
|
||
|
||
}
|