/// <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); }
/// <summary> /// 创建批量推送消息,后续利用生成的 pushid 配合 PushAccountListMultiple /// 或 PushDeviceListMultiple 接口使用,限iOS系统使用。 /// </summary> /// <param name="msg"></param> /// <param name="env"></param> /// <returns></returns> public string CreateMultipush(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.message_type, msg.getType() }, { Constants.message, msg.toJson() }, { Constants.timestamp, GetTimestamp() }, { Constants.environment, env } }; var ret = callRestful(RESTAPI_CREATEMULTIPUSH, param); return(ret); }
/// <summary> /// 推送账号列表,限iOS系统使用。 /// </summary> /// <param name="accountList"></param> /// <param name="msg"></param> /// <param name="env"></param> /// <returns></returns> public string PushAccountList(IEnumerable <string> accountList, 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.account_list, toJArray(accountList) }, { Constants.message_type, msg.getType() }, { Constants.message, msg.toJson() }, { Constants.timestamp, GetTimestamp() }, { Constants.environment, env } }; var ret = callRestful(RESTAPI_PUSHACCOUNTLIST, param); return(ret); }