Пример #1
0
 /// <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, MessageIOS 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.Type.ToString());
     parameters.Add("tags_list", JsonConvert.SerializeObject(tagList));
     parameters.Add("tags_op", tagOp);
     parameters.Add("expire_time",msg.ExpireTime.ToString());
     parameters.Add("send_time", msg.SendTime);
     parameters.Add("environment", environment.ToString());
     if (msg.LoopInterval > 0 && msg.LoopTimes > 0)
     {
         parameters.Add("loop_interval", msg.LoopInterval.ToString());
         parameters.Add("loop_times", msg.LoopTimes.ToString());
     }
     return CallRestful(XinGeConfig.RESTAPI_PUSHTAGS, parameters);
 }
Пример #2
0
 /// <summary>
 /// IOS平台推送消息给单个账号
 /// </summary>
 /// <param name="accessId"></param>
 /// <param name="secretKey"></param>
 /// <param name="content"></param>
 /// <param name="account"></param>
 /// <param name="env"></param>
 /// <returns></returns>
 public static Ret PushAccountIos(long accessId, String secretKey, String content, String account, uint env)
 {
     var message = new MessageIOS
     {
         AlertStr = content,
         Badge = 1,
         Sound = "beep.wave"
     };
     XingeApp xinge = new XingeApp(accessId, secretKey);
     return xinge.PushSingleAccount(account, message, env);
 }
Пример #3
0
        /// <summary>
        /// 推送到 单个用户 IOS
        /// </summary>
        /// <param name="Account">账号</param>
        /// <param name="msg">信息</param>
        /// <param name="environment">推送环境(开发or在线)</param>
        /// <returns>返回值json反序列化后的类</returns>
        public Ret PushSingleAccount(string Account, MessageIOS 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.SendTime);
            parameters.Add("environment", environment.ToString());
            parameters.Add("expire_time", msg.ExpireTime.ToString());
            parameters.Add("message", msg.ToJson());
            parameters.Add("message_type", msg.Type.ToString());
            return CallRestful(XinGeConfig.RESTAPI_PUSHSINGLEACCOUNT, parameters);
        }
Пример #4
0
 /// <summary>
 /// 推送到 单个设备 IOS
 /// </summary>
 /// <param name="deviceToken"></param>
 /// <param name="msg"></param>
 /// <param name="environment"></param>
 /// <returns>返回值json反序列化后的类</returns>
 public Ret PushSingleDevice(string deviceToken, MessageIOS 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.SendTime);
     parameters.Add("environment", environment.ToString());
     parameters.Add("expire_time", msg.ExpireTime.ToString());
     parameters.Add("message", msg.ToJson());
     parameters.Add("message_type", msg.Type.ToString());
     return CallRestful(XinGeConfig.RESTAPI_PUSHSINGLEDEVICE, parameters);
 }
Пример #5
0
        /// <summary>
        /// 推送到所有ios设备
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="environment"></param>
        /// <returns>返回值json反序列化后的类</returns>
        public Ret PushAllDevice(MessageIOS msg, uint environment)
        {
            if (msg == null)
            {
                throw new ArgumentNullException("msg");
            }
            IDictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("expire_time", msg.ExpireTime.ToString());
            parameters.Add("message", msg.ToJson());
            parameters.Add("message_type", msg.Type.ToString());
            parameters.Add("send_time", msg.SendTime);
            if (msg.LoopInterval > 0 && msg.LoopTimes > 0)
            {
                parameters.Add("loop_interval", msg.LoopInterval.ToString());
                parameters.Add("loop_times", msg.LoopTimes.ToString());
            }
            parameters.Add("environment", environment.ToString());

            return CallRestful(XinGeConfig.RESTAPI_PUSHALLDEVICE, parameters);
        }
Пример #6
0
 /// <summary>
 /// 推送消息给多个账号(iOS)
 /// </summary>
 /// <param name="accountList">目标账号,最大限制100</param>
 /// <param name="msg"></param>
 /// <param name="environment"></param>
 /// <returns>返回值json反序列化后的类</returns>
 public Ret PushAccountList(List<String> accountList, MessageIOS 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));
     parameters.Add("expire_time", msg.ExpireTime.ToString());
     parameters.Add("message", msg.ToJson());
     parameters.Add("message_type", msg.Type.ToString());
     parameters.Add("environment", environment.ToString());
     return CallRestful(XinGeConfig.RESTAPI_PUSHACCOUNTLIST, parameters);
 }
Пример #7
0
 /// <summary>
 /// 创建大批量推送消息
 /// </summary>
 /// <param name="msg">IOS通知</param>
 /// <param name="environment">环境</param>
 /// <returns></returns>
 public Ret CreateMultiPush(MessageIOS msg, uint environment)
 {
     IDictionary<string, string> parameters = new Dictionary<string, string>();
     parameters.Add("message", msg.ToJson());
     parameters.Add("message_type", msg.Type.ToString());
     parameters.Add("expire_time", msg.ExpireTime.ToString());
     parameters.Add("environment", environment.ToString());
     return CallRestful(XinGeConfig.RESTAPI_CREATEMULTIPUSH, parameters);
 }
Пример #8
0
        /// <summary>
        /// IOS平台推送消息给标签选中设备
        /// </summary>
        /// <param name="accessId"></param>
        /// <param name="secretKey"></param>
        /// <param name="content"></param>
        /// <param name="tag"></param>
        /// <param name="env"></param>
        /// <returns></returns>
        public static Ret PushTagIos(long accessId, String secretKey, String content, String tag, uint env)
        {
            var message = new MessageIOS
            {
                AlertStr = content,
                Badge = 1,
                Sound = "beep.wave"
            };

            XingeApp xinge = new XingeApp(accessId, secretKey);
            List<String> tagList = new List<String>();
            tagList.Add(tag);
            return xinge.PushTags(tagList, "OR", message, env);
        }
Пример #9
0
        static void Main(string[] args)
        {
            XingeApp xinge = new XingeApp(2200123456, "4ab910b0e8af8b892e0b0bb31af68119");
            Message mandroid = new Message
            {
                Title = "title",
                Content = "content",
                Type = Message.TYPE_NOTIFICATION
            };
            MessageIOS mios=new MessageIOS
            {
                AlertStr = "这是一个简单的alert",
                Badge = 1,
                Sound = "beep.wave"
            };
            string deviceToken = "2e9742d51d1fb1e7d2a7897035cfb93da8f7d9c60e6259adfcf78b878bd956f8";
            //Push消息(包括通知和透传消息)给单个设备
            Ret ret = xinge.PushSingleDevice(deviceToken, mios, XinGeConfig.IOSENV_DEV);
            Console.WriteLine(ret.ret_code);
            xinge.PushSingleDevice("deviceToken", mandroid);
            //Push消息(包括通知和透传消息)给单个账户或别名
            xinge.PushSingleAccount("account", mandroid);
            xinge.PushSingleAccount("account", mios, XinGeConfig.IOSENV_DEV);
            //Push消息(包括通知和透传消息)给app的所有设备
            xinge.PushAllDevice(mandroid);
            xinge.PushAllDevice(mios, XinGeConfig.IOSENV_DEV);

            //创建大批量推送消息
            Ret pushRet = xinge.CreateMultiPush(mios, XinGeConfig.IOSENV_DEV);
            if (pushRet.ret_code == 0)
            {
                JObject json = pushRet.result;
                int pushId = json.GetValue("push_id").Value<int>();

                //Push消息给大批量账号
                xinge.PushAccountListMultiple(pushId, new List<string>() { "account1", "account2" });
                //Push消息给大批量设备
                xinge.PushDeviceListMultiple(pushId, new List<string>() { "token1", "token2" });
            }

            //查询群发消息发送状态
            xinge.QueryPushStatus(new List<string>() { "pushId1", "pushId1" });
            //查询应用覆盖的设备数
            xinge.QueryDeviceCount();
            //Push消息(包括通知和透传消息)给tags指定的设备
            xinge.PushTags(new List<string>() { "tag1", "tag2" }, "OR", mandroid);
            xinge.PushTags(new List<string>() { "tag1", "tag2" }, "OR", mios, XinGeConfig.IOSENV_DEV);
            //查询应用的Tags
            xinge.QueryTags(0, 100);
            //取消尚未触发的定时群发任务
            xinge.CancelTimingPush("pushId1");
            //批量设置标签
            var tags = new Dictionary<string, string>();
            tags.Add("tag1", "token1");
            xinge.BatchSetTag(tags);
            //批量删除标签
            xinge.BatchDelTag(tags);
            //查询应用某token设置的标签
            xinge.QueryTokenTags("deviceToken");
            //查询应用某标签关联的设备数量
            xinge.QueryTagTokenNum("tag");
        }