/// <summary> /// 通过tag推送到ios设备 /// </summary> /// <param name="tagList"></param> /// <param name="tagOp"></param> /// <param name="msg"></param> /// <param name="environment"></param> /// <returns>返回值json反序列化后的类</returns> public Ret pushTags(List <String> tagList, String tagOp, Msg_IOS msg, uint environment) { if (tagList == null || tagList.Count == 0) { throw new ArgumentNullException("tagList"); } IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("message", msg.ToJson()); parameters.Add("message_type", msg.message_type.ToString()); parameters.Add("tags_list", JsonConvert.SerializeObject(tagList)); parameters.Add("tags_op", tagOp); if (msg.expire_time.HasValue) { parameters.Add("expire_time", msg.expire_time.Value.ToString()); } parameters.Add("send_time", msg.send_time); parameters.Add("environment", environment.ToString()); if (msg.loop_times.HasValue) { parameters.Add("loop_times", msg.loop_times.Value.ToString()); } if (msg.loop_interval.HasValue) { parameters.Add("loop_interval", msg.ToJson()); } return(CallRestful(XinGeConfig.RESTAPI_PUSHTAGS, parameters)); }
/// <summary> /// 推送到所有android设备 /// </summary> /// <param name="msg"></param> /// <param name="environment"></param> /// <returns>返回值json反序列化后的类</returns> public Ret PushAllDevice(Msg_IOS msg, uint environment) { if (msg == null) { throw new ArgumentNullException("msg"); } IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("message_type", msg.message_type.ToString()); if (msg.expire_time.HasValue) { parameters.Add("expire_time", msg.expire_time.Value.ToString()); } parameters.Add("send_time", msg.send_time); parameters.Add("multi_pkg", environment.ToString()); parameters.Add("message", msg.ToJson()); if (msg.loop_times.HasValue) { parameters.Add("loop_times", msg.loop_times.Value.ToString()); } if (msg.loop_interval.HasValue) { parameters.Add("loop_interval", msg.ToJson()); } return(CallRestful(XinGeConfig.RESTAPI_PUSHALLDEVICE, parameters)); }
/// <summary> /// /// </summary> /// <param name="accountList"></param> /// <param name="msg"></param> /// <param name="environment"></param> /// <returns>返回值json反序列化后的类</returns> public Ret PushAccountList(List <String> accountList, Msg_IOS msg, uint environment) { if (msg == null) { throw new ArgumentNullException("msg"); } if (accountList.Count == 0) { throw new ArgumentNullException("accountList"); } if (accountList.Count > 100) { throw new ArgumentOutOfRangeException("accountList"); } IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("account_list", JsonConvert.SerializeObject(accountList)); if (msg.expire_time.HasValue) { parameters.Add("expire_time", msg.expire_time.Value.ToString()); } parameters.Add("message", msg.ToJson()); parameters.Add("environment", environment.ToString()); parameters.Add("message_type", msg.message_type.ToString()); return(CallRestful(XinGeConfig.RESTAPI_PUSHACCOUNTLIST, parameters)); }
static void Main(string[] args) { XingeApp xinge = new XingeApp("accessId", "secretKey"); Payload pl = new Payload("这是一个简单的alert"); Msg_IOS mios = new Msg_IOS(pl); Msg_Android mandroid = new Msg_Android_TouChuan("测试", XinGeConfig.message_type_touchuan) { content = "测试" }; //Push消息(包括通知和透传消息)给单个设备 xinge.PushToSingleDevice("DeviceToken", mios, XinGeConfig.IOSENV_DEV); xinge.PushToSingleDevice("DeviceToken", mandroid); //Push消息(包括通知和透传消息)给单个账户或别名 xinge.PushToAccount("account", mandroid); xinge.PushToAccount("account", mios, XinGeConfig.IOSENV_DEV); //Push消息(包括通知和透传消息)给多个账户或别名(批量推送) xinge.PushAccountList(new List<string>() { "account1" ,"account2"}, mandroid); xinge.PushAccountList(new List<string>() { "account1", "account2" }, mios, XinGeConfig.IOSENV_DEV); //Push消息(包括通知和透传消息)给app的所有设备 xinge.PushAllDevice(mandroid); xinge.PushAllDevice(mios,XinGeConfig.IOSENV_DEV); //Push消息(包括通知和透传消息)给tags指定的设备 xinge.pushTags(new List<string>() { "tag1", "tag1" }, "OR", mandroid); xinge.pushTags(new List<string>() { "tag1", "tag1" }, "OR", mios, XinGeConfig.IOSENV_DEV); //查询群发消息发送状态 xinge.QueryPushStatus(new List<string>() { "pushId1", "pushId1" }); //查询应用覆盖的设备数 xinge.QueryDeviceCount(new List<string>() { "pushId1", "pushId1" }); //查询应用的Tags xinge.QueryTags(0, 100); //取消尚未触发的定时群发任务 xinge.CancelTimingPush("pushId1"); //批量设置标签 var tags = new Dictionary<string, string>(); tags.Add("tag1", "token1"); xinge.BatchSetTag(tags); //批量删除标签 xinge.BatchDelTag(new List<string>() { "tag1", "tag2" }); //查询应用某token设置的标签 xinge.QueryTokenTags("deviceToken"); //查询应用某标签关联的设备数量 xinge.QueryTagTokenNum("tag"); }
/// <summary> /// 推送到 单个设备 IOS /// </summary> /// <param name="DeviceToken"></param> /// <param name="msg"></param> /// <param name="environment"></param> /// <returns>返回值json反序列化后的类</returns> public Ret PushToSingleDevice(string DeviceToken, Msg_IOS msg, uint environment) { if (msg == null) { throw new ArgumentNullException("msg"); } if (string.IsNullOrEmpty(DeviceToken)) { throw new ArgumentNullException("DeviceToken"); } IDictionary<string, string> parameters = new Dictionary<string, string>(); parameters.Add("device_token", DeviceToken); parameters.Add("send_time", msg.send_time); parameters.Add("environment", environment.ToString()); if (msg.expire_time.HasValue) { parameters.Add("expire_time", msg.expire_time.Value.ToString()); } parameters.Add("message", msg.ToJson()); parameters.Add("message_type", msg.message_type.ToString()); return CallRestful(XinGeConfig.RESTAPI_PUSHSINGLEDEVICE, parameters); }
/// <summary> /// 推送到 单个设备 IOS /// </summary> /// <param name="DeviceToken"></param> /// <param name="msg"></param> /// <param name="environment"></param> /// <returns>返回值json反序列化后的类</returns> public Ret PushToSingleDevice(string DeviceToken, Msg_IOS msg, uint environment) { if (msg == null) { throw new ArgumentNullException("msg"); } if (string.IsNullOrEmpty(DeviceToken)) { throw new ArgumentNullException("DeviceToken"); } IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("device_token", DeviceToken); parameters.Add("send_time", msg.send_time); parameters.Add("environment", environment.ToString()); if (msg.expire_time.HasValue) { parameters.Add("expire_time", msg.expire_time.Value.ToString()); } parameters.Add("message", msg.ToJson()); parameters.Add("message_type", msg.message_type.ToString()); return(CallRestful(XinGeConfig.RESTAPI_PUSHSINGLEDEVICE, parameters)); }
/// <summary> /// 推送到 单个用户 IOS /// </summary> /// <param name="Account">账号</param> /// <param name="msg">信息</param> /// <param name="environment">推送环境(开发or在线)</param> /// <returns>返回值json反序列化后的类</returns> public Ret PushToAccount(string Account, Msg_IOS msg, uint environment) { if (msg == null) { throw new ArgumentNullException("msg"); } if (string.IsNullOrEmpty(Account)) { throw new ArgumentNullException("Account"); } IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("account", Account); parameters.Add("send_time", msg.send_time); parameters.Add("environment", environment.ToString()); if (msg.expire_time.HasValue) { parameters.Add("expire_time", msg.expire_time.Value.ToString()); } parameters.Add("message", msg.ToJson()); parameters.Add("message_type", msg.message_type.ToString()); return(CallRestful(XinGeConfig.RESTAPI_PUSHSINGLEACCOUNT, parameters)); }
/// <summary> /// 通过tag推送到ios设备 /// </summary> /// <param name="tagList"></param> /// <param name="tagOp"></param> /// <param name="msg"></param> /// <param name="environment"></param> /// <returns>返回值json反序列化后的类</returns> public Ret pushTags(List<String> tagList, String tagOp, Msg_IOS msg, uint environment) { if (tagList == null || tagList.Count == 0) { throw new ArgumentNullException("tagList"); } IDictionary<string, string> parameters = new Dictionary<string, string>(); parameters.Add("message", msg.ToJson()); parameters.Add("message_type", msg.message_type.ToString()); parameters.Add("tags_list", JsonConvert.SerializeObject(tagList)); parameters.Add("tags_op", tagOp); if (msg.expire_time.HasValue) { parameters.Add("expire_time", msg.expire_time.Value.ToString()); } parameters.Add("send_time", msg.send_time); parameters.Add("environment", environment.ToString()); if (msg.loop_times.HasValue) { parameters.Add("loop_times", msg.loop_times.Value.ToString()); } if (msg.loop_interval.HasValue) { parameters.Add("loop_interval", msg.ToJson()); } return CallRestful(XinGeConfig.RESTAPI_PUSHTAGS, parameters); }
/// <summary> /// 推送到所有android设备 /// </summary> /// <param name="msg"></param> /// <param name="environment"></param> /// <returns>返回值json反序列化后的类</returns> public Ret PushAllDevice(Msg_IOS msg, uint environment) { if (msg == null) { throw new ArgumentNullException("msg"); } IDictionary<string, string> parameters = new Dictionary<string, string>(); parameters.Add("message_type", msg.message_type.ToString()); if (msg.expire_time.HasValue) { parameters.Add("expire_time", msg.expire_time.Value.ToString()); } parameters.Add("send_time", msg.send_time); parameters.Add("multi_pkg", environment.ToString()); parameters.Add("message", msg.ToJson()); if (msg.loop_times.HasValue) { parameters.Add("loop_times", msg.loop_times.Value.ToString()); } if (msg.loop_interval.HasValue) { parameters.Add("loop_interval", msg.ToJson()); } return CallRestful(XinGeConfig.RESTAPI_PUSHALLDEVICE, parameters); }
/// <summary> /// /// </summary> /// <param name="accountList"></param> /// <param name="msg"></param> /// <param name="environment"></param> /// <returns>返回值json反序列化后的类</returns> public Ret PushAccountList(List<String> accountList, Msg_IOS msg, uint environment) { if (msg == null) { throw new ArgumentNullException("msg"); } if (accountList.Count == 0) { throw new ArgumentNullException("accountList"); } if (accountList.Count > 100) { throw new ArgumentOutOfRangeException("accountList"); } IDictionary<string, string> parameters = new Dictionary<string, string>(); parameters.Add("account_list", JsonConvert.SerializeObject(accountList)); if (msg.expire_time.HasValue) { parameters.Add("expire_time", msg.expire_time.Value.ToString()); } parameters.Add("message", msg.ToJson()); parameters.Add("environment", environment.ToString()); parameters.Add("message_type", msg.message_type.ToString()); return CallRestful(XinGeConfig.RESTAPI_PUSHACCOUNTLIST, parameters); }
/// <summary> /// 推送到 单个用户 IOS /// </summary> /// <param name="Account">账号</param> /// <param name="msg">信息</param> /// <param name="environment">推送环境(开发or在线)</param> /// <returns>返回值json反序列化后的类</returns> public Ret PushToAccount(string Account, Msg_IOS msg, uint environment) { if (msg == null) { throw new ArgumentNullException("msg"); } if (string.IsNullOrEmpty(Account)) { throw new ArgumentNullException("Account"); } IDictionary<string, string> parameters = new Dictionary<string, string>(); parameters.Add("account", Account); parameters.Add("send_time", msg.send_time); parameters.Add("environment", environment.ToString()); if (msg.expire_time.HasValue) { parameters.Add("expire_time", msg.expire_time.Value.ToString()); } parameters.Add("message", msg.ToJson()); parameters.Add("message_type", msg.message_type.ToString()); return CallRestful(XinGeConfig.RESTAPI_PUSHSINGLEACCOUNT, parameters); }