个推推送前端技术架构用到Unipush结合使用不然不能走厂商通道
@Value("${sgmw.app.appId}")
private String appId;
@Value("${sgmw.app.appKey}")
private String appKey;
@Value("${sgmw.app.masterSecret}")
private String masterSecret;
@Value("${sgmw.app.host}")
private String host;
public void pushInfo() {
// 配置返回每个用户返回用户状态,可选
System.setProperty(“gexin_pushList_needDetails”, “true”);
// 配置返回每个别名及其对应cid的用户状态,可选
// System.setProperty(“gexin_pushList_needAliasDetails”, “true”);
IGtPush push = new IGtPush(host, appKey, masterSecret);
// 通知透传模板
TransmissionTemplate template = notificationTemplateDemo();
ListMessage message = new ListMessage();
message.setData(template);
// 设置消息离线,并设置离线时间
message.setOffline(true);
// 离线有效时间,单位为毫秒
message.setOfflineExpireTime(24 * 1000 * 3600);
// 配置推送目标
List targets = new ArrayList();
String CID1=“a5c712eebb96aa9d5c496769fbae5625”;
List clientIds = pushListToAPPMapper.selectClientIdsByTable();
for (String clientId : clientIds) {
Target target1 = new Target();
target1.setAppId(appId);
target1.setClientId(clientId);
targets.add(target1);
}
// taskId用于在推送时去查找对应的message
String taskId = push.getContentId(message);
IPushResult ret = push.pushMessageToList(taskId, targets);
System.out.println(ret.getResponse().toString());
}
/**
* 群体推送模板
* 具有穿透性模板
*
* @return
*/
public TransmissionTemplate notificationTemplateDemo() {
TransmissionTemplate template = new TransmissionTemplate();
template.setAppId(appId);
template.setAppkey(appKey);
template.setTransmissionContent("请输入需要透传的内容");
template.setTransmissionType(1);
Notify notify = new Notify();
notify.setTitle("推送标题");
notify.setContent("推送内容" + System.currentTimeMillis());
notify.setIntent("intent:#Intent;launchFlags=0x10000000;package=com.pp.yl;component=" +
"你的包名 /com.getui.demo.MainActivity;i.parm1=12;end");
notify.setType(GtReq.NotifyInfo.Type._intent);
// notify.setUrl("https://dev.getui.com/");
//notify.setType(Type._url);
template.set3rdNotifyInfo(notify);//设置第三方通知
return template;
}