コード例 #1
0
        /// <summery> 推送消息给全部设备, 限 iOS 系统使用
        /// <param name = "message"> iOS 消息结构体 </param>
        /// <param name = "environment"> 指定推送环境 </param>
        /// <returns> 推送结果描述 </returns>
        /// </summery>
        public async Task <string> PushAllDevice(MessageiOS message, PushEnvironmentofiOS environment)
        {
            if (!IsValidMessageType(message, environment))
            {
                return("{'ret_code':-1,'err_msg':'message type or environment error!'}");
            }

            if (!message.isValid())
            {
                return("{'ret_code':-1,'err_msg':'message invalid!'}");
            }

            var param = new Dictionary <string, object>
            {
                { "audience_type", "all" },
                { "platform", "ios" },
                // param.Add("access_id", this.xgPushAppAccessKey);
                { "expire_time", message.getExpireTime() },
                { "send_time", message.getSendTime() },
                { "message_type", message.getType() },
                { "message", message.toJson() },
                { "timestamp", (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000 },
                { "environment", environment }
            };

            if (message.getLoopInterval() > 0 && message.getLoopTimes() > 0)
            {
                param.Add("loop_interval", message.getLoopInterval());
                param.Add("loop_times", message.getLoopTimes());
            }

            var ret = await RequestXgServerV3(_xgPushServierHost, _xgPushAppPath, param);

            return(ret);
        }
コード例 #2
0
        /// <summery> 推送消息给绑定账号的设备, 限 iOS 系统使用
        /// <param name = "accountList"> 接收设备标识绑定的账号列表 </param>
        /// <param name = "message"> iOS 消息结构体,注意:第一次推送时,message中的pushID是填写0,若需要再次推送同样的文本,需要根据返回的push_id填写 </param>
        /// <param name = "environment"> 指定推送环境 </param>
        /// <returns> 推送结果描述 </returns>
        /// </summery>
        public async Task <string> PushAccountList(List <string> accountList, MessageiOS message,
                                                   PushEnvironmentofiOS environment)
        {
            if (!IsValidMessageType(message, environment))
            {
                return("{'ret_code':-1,'err_msg':'message type or environment error!'}");
            }

            if (!message.isValid())
            {
                return("{'ret_code':-1,'err_msg':'message invalid!'}");
            }

            var param = new Dictionary <string, object>
            {
                { "audience_type", "account_list" },
                { "platform", "ios" },
                // param.Add("access_id", this.xgPushAppAccessKey);
                { "expire_time", message.getExpireTime() },
                { "send_time", message.getSendTime() },
                { "account_list", ToJArray(accountList) },
                { "message_type", message.getType() },
                { "message", message.toJson() },
                { "push_id", message.getPushID().ToString() },
                { "timestamp", (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000 },
                { "environment", environment }
            };
            var ret = await RequestXgServerV3(_xgPushServierHost, _xgPushAppPath, param);

            return(ret);
        }
コード例 #3
0
        /// <summery> 推送消息给全部设备, 限 iOS 系统使用
        /// <param name = "message"> iOS 消息结构体 </param>
        /// <param name = "environment"> 指定推送环境 </param>
        /// <returns> 推送结果描述 </returns>
        /// </summery>
        public string PushAllDevice(MessageiOS message, PushEnvironmentofiOS environment)
        {
            if (!isValidMessageType(message, environment))
            {
                return("{'ret_code':-1,'err_msg':'message type or environment error!'}");
            }
            if (!message.isValid())
            {
                return("{'ret_code':-1,'err_msg':'message invalid!'}");
            }
            Dictionary <string, object> param = new Dictionary <string, object>();

            param.Add("audience_type", "all");
            param.Add("platform", "ios");
            // param.Add("access_id", this.xgPushAppAccessKey);
            param.Add("expire_time", message.getExpireTime());
            param.Add("send_time", message.getSendTime());
            param.Add("message_type", message.getType());
            param.Add("message", message.toJson());
            param.Add("timestamp", (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000);
            param.Add("environment", environment);
            if (message.getLoopInterval() > 0 && message.getLoopTimes() > 0)
            {
                param.Add("loop_interval", message.getLoopInterval());
                param.Add("loop_times", message.getLoopTimes());
            }
            string ret = requestXGServerV3(XingeApp.XGPushServierHost, XingeApp.XGPushAppPath, param);

            return(ret);
        }
コード例 #4
0
        /// <summery> 推送消息给绑定账号的设备, 限 iOS 系统使用
        /// <param name = "accountList"> 接收设备标识绑定的账号列表 </param>
        /// <param name = "message"> iOS 消息结构体,注意:第一次推送时,message中的pushID是填写0,若需要再次推送同样的文本,需要根据返回的push_id填写 </param>
        /// <param name = "environment"> 指定推送环境 </param>
        /// <returns> 推送结果描述 </returns>
        /// </summery>
        public string PushAccountList(List <string> accountList, MessageiOS message, PushEnvironmentofiOS environment)
        {
            if (!isValidMessageType(message, environment))
            {
                return("{'ret_code':-1,'err_msg':'message type or environment error!'}");
            }
            if (!message.isValid())
            {
                return("{'ret_code':-1,'err_msg':'message invalid!'}");
            }
            Dictionary <string, object> param = new Dictionary <string, object>();

            param.Add("audience_type", "account_list");
            param.Add("platform", "ios");
            // param.Add("access_id", this.xgPushAppAccessKey);
            param.Add("expire_time", message.getExpireTime());
            param.Add("send_time", message.getSendTime());
            param.Add("account_list", toJArray(accountList));
            param.Add("message_type", message.getType());
            param.Add("message", message.toJson());
            param.Add("push_id", message.getPushID().ToString());
            param.Add("timestamp", (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000);
            param.Add("environment", environment);
            string ret = requestXGServerV3(XingeApp.XGPushServierHost, XingeApp.XGPushAppPath, param);

            return(ret);
        }
コード例 #5
0
        /// <summery> 推送消息给指定设备, 限 iOS 系统使用
        /// <param name = "deviceToken"> 接收消息的设备标识 </param>
        /// <param name = "message"> iOS 消息结构体 </param>
        /// <param name = "environment"> 指定推送环境 </param>
        /// <returns> 推送结果描述 </returns>
        /// </summery>
        public async Task <string> PushSingleDevice(string deviceToken, MessageiOS message,
                                                    PushEnvironmentofiOS environment)
        {
            if (!IsValidMessageType(message, environment))
            {
                return("{'ret_code':-1,'err_msg':'message type or environment error!'}");
            }

            if (!message.isValid())
            {
                return("{'ret_code':-1,'err_msg':'message invalid!'}");
            }

            var param = new Dictionary <string, object>
            {
                { "audience_type", "token" },
                { "platform", "ios" }
            };

            var tokenList = new List <string> {
                deviceToken
            };

            param.Add("token_list", ToJArray(tokenList));

            // param.Add("access_id", this.xgPushAppAccessKey);
            param.Add("expire_time", message.getExpireTime());
            param.Add("send_time", message.getSendTime());
            // param.Add("device_token", deviceToken);
            param.Add("message_type", "notify");

            param.Add("message", message.toJson());
            param.Add("timestamp", (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000);
            param.Add("environment", environment);
            if (message.getLoopInterval() > 0 && message.getLoopTimes() > 0)
            {
                param.Add("loop_interval", message.getLoopInterval());
                param.Add("loop_times", message.getLoopTimes());
            }

            Console.WriteLine(param);
            var ret = await RequestXgServerV3(_xgPushServierHost, _xgPushAppPath, param);

            return(ret);
        }
コード例 #6
0
        /// <summery> 推送消息给指定设备, 限 iOS 系统使用
        /// <param name = "deviceToken"> 接收消息的设备标识 </param>
        /// <param name = "message"> iOS 消息结构体 </param>
        /// <param name = "environment"> 指定推送环境 </param>
        /// <returns> 推送结果描述 </returns>
        /// </summery>
        public string PushSingleDevice(string deviceToken, MessageiOS message, PushEnvironmentofiOS environment)
        {
            if (!isValidMessageType(message, environment))
            {
                return("{'ret_code':-1,'err_msg':'message type or environment error!'}");
            }
            if (!message.isValid())
            {
                return("{'ret_code':-1,'err_msg':'message invalid!'}");
            }
            Dictionary <string, object> param = new Dictionary <string, object>();

            param.Add("audience_type", "token");
            param.Add("platform", "ios");

            List <string> tokenList = new List <string>();

            tokenList.Add(deviceToken);
            param.Add("token_list", toJArray(tokenList));

            // param.Add("access_id", this.xgPushAppAccessKey);
            param.Add("expire_time", message.getExpireTime());
            param.Add("send_time", message.getSendTime());
            // param.Add("device_token", deviceToken);
            param.Add("message_type", "notify");

            param.Add("message", message.toJson());
            param.Add("timestamp", (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000);
            param.Add("environment", environment);
            if (message.getLoopInterval() > 0 && message.getLoopTimes() > 0)
            {
                param.Add("loop_interval", message.getLoopInterval());
                param.Add("loop_times", message.getLoopTimes());
            }
            System.Console.WriteLine(param);
            string ret = requestXGServerV3(XingeApp.XGPushServierHost, XingeApp.XGPushAppPath, param);

            return(ret);
        }