/// <summary> /// 推送单个设备,限iOS系统使用。 /// </summary> /// <param name="deviceToken"></param> /// <param name="msg"></param> /// <param name="env"></param> /// <returns></returns> public string PushSingleDevice(string deviceToken, MessageIOS msg, iOSEnvironment env) { if (!isValidMessageType(msg, env)) { return("{'ret_code':-1,'err_msg':'message type or environment error!'}"); } if (!msg.isValid()) { return("{'ret_code':-1,'err_msg':'message invalid!'}"); } var param = new Dictionary <string, object> { { Constants.access_id, m_access_id }, { Constants.expire_time, msg.getExpireTime() }, { Constants.send_time, msg.getSendTime() }, { Constants.device_token, deviceToken }, { Constants.message_type, msg.getType() }, { Constants.message, msg.toJson() }, { Constants.timestamp, GetTimestamp() }, { Constants.environment, env } }; if (msg.getLoopInterval() > 0 && msg.getLoopTimes() > 0) { param.Add(Constants.loop_interval, msg.getLoopInterval()); param.Add(Constants.loop_times, msg.getLoopTimes()); } var ret = callRestful(RESTAPI_PUSHSINGLEDEVICE, param); return(ret); }
/// <summary> /// 推送标签,限iOS系统使用。 /// </summary> /// <param name="tagList"></param> /// <param name="tagOp"></param> /// <param name="msg"></param> /// <param name="env"></param> /// <returns></returns> public string PushTags(IEnumerable <string> tagList, Operator tagOp, MessageIOS msg, iOSEnvironment env) { if (!isValidMessageType(msg, env)) { return("{'ret_code':-1,'err_msg':'message type or environment error!'}"); } if (!msg.isValid()) { return("{'ret_code':-1,'err_msg':'message invalid!'}"); } var param = new Dictionary <string, object> { { Constants.access_id, m_access_id }, { Constants.expire_time, msg.getExpireTime() }, { Constants.send_time, msg.getSendTime() }, { Constants.message_type, msg.getType() }, { Constants.tags_list, toJArray(tagList) }, { Constants.tags_op, tagOp }, { Constants.message, msg.toJson() }, { Constants.timestamp, (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000 }, { Constants.environment, env } }; if (msg.getLoopInterval() > 0 && msg.getLoopTimes() > 0) { param.Add(Constants.loop_interval, msg.getLoopInterval()); param.Add(Constants.loop_times, msg.getLoopTimes()); } var ret = callRestful(RESTAPI_PUSHTAGS, param); return(ret); }