package com.huimv.gtpush; import java.util.ArrayList; import java.util.List; import com.gexin.rp.sdk.base.IPushResult; import com.gexin.rp.sdk.base.impl.ListMessage; import com.gexin.rp.sdk.base.impl.Target; import com.gexin.rp.sdk.http.IGtPush; import com.gexin.rp.sdk.template.TransmissionTemplate; public class PushtoList { static String appId = "ryrmlQRgev7B0patik5yM1"; static String appkey = "EBN73liO6N8L0ubna5JLc3"; static String master = "qRTTLUjkU77NH0lbjOIz98"; static String host = "http://sdk.open.api.igexin.com/serviceex"; public static void main(String[] args) throws Exception { //配置返回每个用户返回用户状态,可选 System.setProperty("gexin.rp.sdk.pushlist.needDetails", "true"); IGtPush push = new IGtPush(host, appkey, master); //通知透传模板 TransmissionTemplate template = notificationTemplateDemo(); ListMessage message = new ListMessage(); message.setData(template); //设置消息离线,并设置离线时间 message.setOffline(true); //离线有效时间,单位为毫秒,可选 message.setOfflineExpireTime(24*1000*3600); //配置推送目标 List targets = new ArrayList(); Target target1 = new Target(); target1.setAppId(appId); target1.setAlias("hzhm"); targets.add(target1); //获取taskID String taskId = push.getContentId(message); //使用taskID对目标进行推送 IPushResult ret = push.pushMessageToList(taskId, targets); //打印服务器返回信息 System.out.println(ret.getResponse().toString()); } public static TransmissionTemplate notificationTemplateDemo() { TransmissionTemplate template = new TransmissionTemplate(); template.setAppId(appId); template.setAppkey(appkey); // 透传消息设置,1为强制启动应用,客户端接收到消息后就会立即启动应用;2为等待应用启动。 template.setTransmissionType(2); template.setTransmissionContent("44"); return template; } }