/// <summary> /// 推送消息到移动端App。 /// </summary> /// <param name="billAction">本次消息对应的单据操作种类。不同的app支持的操作种类不一样。</param> /// <param name="paramObj"></param> public static void PushCore(BillAction billAction, LibMailParam paramObj) { LibMailParam param = paramObj as LibMailParam; try { List <PushTarget> listTarget = GetPushTarget(billAction, param.PersonId, param.To, param.CC); if (listTarget == null || listTarget.Count == 0) { return; } NoticeMsg msg = new NoticeMsg() { Message = param.Content, Title = param.Subject }; PushParams pushParams = new PushParams() { Message = msg, Targets = listTarget }; //调用服务接口推送 LibAppPushService.Push(pushParams); } catch { //throw; } }
internal override void _NoticeMsg(string msg) { NoticeMsg?.Invoke(msg); }
protected TransmissionTemplate TransmissionTemplateDemo(AppPushChannelInfo channelInfo, NoticeMsg message) { if (channelInfo == null) { throw new Exception("推送通道信息为空。"); } TransmissionTemplate template = new TransmissionTemplate(); try { template.AppId = channelInfo.AppId; template.AppKey = channelInfo.AppKey; //应用启动类型,1:强制应用启动 2:等待应用启动 template.TransmissionType = "1"; //透传内容 template.TransmissionContent = "透传内容"; //设置通知定时展示时间,结束时间与开始时间相差需大于6分钟,消息推送后,客户端将在指定时间差内展示消息(误差6分钟) //String begin = "2017-03-13 00:36:10"; //String end = "2017-03-13 23:46:20"; //template.setDuration(begin, end); //APN高级推送 开始 APNPayload apnpayload = new APNPayload(); DictionaryAlertMsg alertMsg = new DictionaryAlertMsg(); alertMsg.Body = message.Message; //alertMsg.Body = "您有新的异常消息,请尽快处理。"; //(用于多语言支持)指定执行按钮所使用的Localizable.strings //alertMsg.ActionLocKey = "ActionLocKey"; //(用于多语言支持)指定Localizable.strings文件中相应的key //alertMsg.LocKey = "LocKey"; ////如果loc-key中使用的占位符,则在loc-args中指定各参数 //alertMsg.addLocArg("LocArg"); //指定启动界面图片名 //alertMsg.LaunchImage = "LaunchImage"; //iOS8.2支持字段 //通知标题 alertMsg.Title = message.Title; //(用于多语言支持)对于标题指定执行按钮所使用的Localizable.strings //alertMsg.TitleLocKey = "TitleLocKey"; //对于标题, 如果loc-key中使用的占位符,则在loc-args中指定各参数 //alertMsg.addTitleLocArg("TitleLocArg"); apnpayload.AlertMsg = alertMsg; //应用icon上显示的数字 //apnpayload.Badge = 1; apnpayload.ContentAvailable = 1; //apnpayload.Category = ""; //通知铃声文件名 //apnpayload.Sound = "test1.wav"; //增加自定义的数据 apnpayload.addCustomMsg("pushMsgType", "message"); template.setAPNInfo(apnpayload); //APN高级推送 结束 } catch (Exception) { throw; } return(template); }