private TransmissionTemplate TransmissionTemplateIOS(string title) { TransmissionTemplate template = new TransmissionTemplate(); template.AppId = APPID; template.AppKey = APPKEY; template.TransmissionType = "2"; //应用启动类型,1:强制应用启动 2:等待应用启动 template.TransmissionContent = ""; //透传内容 //iOS简单推送 //APNPayload apnpayload = new APNPayload(); //SimpleAlertMsg alertMsg = new SimpleAlertMsg("alertMsg"); //apnpayload.AlertMsg = alertMsg; //apnpayload.Badge = 11; //apnpayload.ContentAvailable = 1; //apnpayload.Category = ""; //apnpayload.Sound = ""; //apnpayload.addCustomMsg("", ""); //template.setAPNInfo(apnpayload); //APN高级推送 APNPayload apnpayload = new APNPayload(); DictionaryAlertMsg alertMsg = new DictionaryAlertMsg(); alertMsg.Body = "Body"; alertMsg.ActionLocKey = "查看"; alertMsg.LocKey = title; alertMsg.addLocArg("LocArg"); alertMsg.LaunchImage = "LaunchImage"; //IOS8.2支持字段 //alertMsg.Title = "Title"; //alertMsg.TitleLocKey = "TitleLocKey"; //alertMsg.addTitleLocArg("TitleLocArg"); apnpayload.AlertMsg = alertMsg; apnpayload.Badge = 1; apnpayload.ContentAvailable = 1; //apnpayload.Category = ""; apnpayload.Sound = "test1.wav"; apnpayload.addCustomMsg("payload", "payload"); template.setAPNInfo(apnpayload); //设置客户端展示时间 //String begin = "2015-03-06 14:28:10"; //String end = "2015-03-06 14:38:20"; //template.setDuration(begin, end); return template; }
//PushMessageToSingle接口测试代码 private static void PushMessageToSingle() { // 推送主类 IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET); //通知模版:支持TransmissionTemplate、LinkTemplate、NotificationTemplate,此处以TransmissionTemplate为例 TransmissionTemplate template = new TransmissionTemplate(); template.AppId = APPID; // 应用APPID template.AppKey = APPKEY; // 应用APPKEY template.TransmissionType = "1"; // 收到消息是否立即启动应用,1为立即启动,2则广播等待客户端自启动 template.TransmissionContent = "您需要透传的内容"; // 需要透传的内容 //iOS推送需要的pushInfo字段 //template.setPushInfo(actionLocKey, badge, message, sound, payload, locKey, locArgs, launchImage); // 单推消息模型 SingleMessage message = new SingleMessage(); message.IsOffline = true; // 用户当前不在线时,是否离线存储,可选 message.OfflineExpireTime = 1000 * 3600 * 12; // 离线有效时间,单位为毫秒,可选 message.Data = template; com.igetui.api.openservice.igetui.Target target = new com.igetui.api.openservice.igetui.Target(); target.appId = APPID; target.clientId = CLIENTID; String pushResult = push.pushMessageToSingle(message, target); System.Console.WriteLine("-----------PushMessageToSingle--------------" + pushResult); }