private void pushMsg(SeatManage.JsonModel.JM_SeatNotice notice) { AppUserInfo app_user = AMS.ServiceProxy.App_UserInfoProxy.GetAppUserInfoByCardNoAndSchoolNum(notice.CardNo, notice.SchoolNum); //TODO:根据学号获取channelId。 BaiduPushNotification notification = new BaiduPushNotification(); notification.title = notice.Title; notification.description = notice.Context; notification.notification_builder_id = 0; notification.notification_basic_style = 7; notification.custom_content = new Custom_content(); string msg = notification.getJsonString(); PushOptions pOpts = new PushOptions(app_user.ChannelId, 1, msg, null, api_key, getTimestamp(), null, Device_Type.Android); BaiduPush.BaiduPush push = new BaiduPush.BaiduPush("POST", secret_key); push.PushSingleDevice(pOpts); }
/// <summary> /// 推送事件(穿透消息) /// </summary> /// <param name="notifyEvent"></param> private void pushEvent(SeatManage.JsonModel.JM_NotifyEvent notifyEvent) { try { AppUserInfo app_user = AMS.ServiceProxy.App_UserInfoProxy.GetAppUserInfoByCardNoAndSchoolNum(notifyEvent.CardNo, notifyEvent.SchoolNum); if (app_user == null) { return; } if (notifyEvent == null) { return; } PushOptions pOpts = new PushOptions(app_user.ChannelId, 0, SeatManage.SeatManageComm.JSONSerializer.Serialize(notifyEvent), null, api_key, getTimestamp(), null, Device_Type.Android); BaiduPush.BaiduPush push = new BaiduPush.BaiduPush("POST", secret_key); string pushResult = push.PushSingleDevice(pOpts); // SeatManage.SeatManageComm.WriteLog.Write("消息推送结果:" + pushResult); } catch (Exception ex) { throw ex; } }