예제 #1
0
        //推送标签,ios设备使用
        public string PushTags(List <string> tagList, string tagOp, MessageIOS message, int 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("access_id", this.m_accessId);
            param.Add("expire_time", message.getExpireTime());
            param.Add("send_time", message.getSendTime());
            param.Add("message_type", message.getType());
            param.Add("tags_list", toJArray(tagList));
            param.Add("tags_op", tagOp);
            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 = callRestful(XingeApp.RESTAPI_PUSHTAGS, param);

            return(ret);
        }
예제 #2
0
        //推送单个设备,ios设备使用,IOSENV_PROD表示生产环境,IOSENV_DEV表示开发环境
        public string PushSingleDevice(string deviceToken, MessageIOS message, int 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("access_id", this.m_accessId);
            param.Add("expire_time", message.getExpireTime());
            param.Add("send_time", message.getSendTime());
            param.Add("device_token", deviceToken);
            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 = callRestful(XingeApp.RESTAPI_PUSHSINGLEDEVICE, param);

            return(ret);
        }
예제 #3
0
 protected Boolean isValidMessageType(MessageIOS message, int environment)
 {
     if (this.m_accessId >= IOS_MIN_ID && (environment == IOSENV_PROD || environment == IOSENV_DEV))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #4
0
        //推送给全部的设备,限IOS系统使用
        public static string pushAllIos(long accessId, string secretKey, string content, int env)
        {
            MessageIOS message = new MessageIOS();

            message.setAlert(content);
            message.setBadge(1);
            message.setSound("beep.wav");

            XingeApp xinge = new XingeApp(accessId, secretKey);
            string   ret   = xinge.PushAllDevice(message, env);

            return(ret);
        }
예제 #5
0
        //推送给绑定标签的设备,限IOS系统使用
        public static string pushTagIos(long accessId, string secretKey, string content, string tag, int env)
        {
            MessageIOS message = new MessageIOS();

            message.setAlert(content);
            message.setBadge(1);
            message.setSound("beep.wav");

            XingeApp      xinge   = new XingeApp(accessId, secretKey);
            List <string> tagList = new List <string>();

            tagList.Add(tag);
            string ret = xinge.PushTags(tagList, "OR", message, env);

            return(ret);
        }
예제 #6
0
        //创建批量推送消息,后续利用生成的pushid配合PushAccountListMultiple或PushDeviceListMultiple接口使用,限ios
        public string CreateMultipush(MessageIOS message, int 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("access_id", this.m_accessId);
            param.Add("expire_time", message.getExpireTime());
            param.Add("message_type", message.getType());
            param.Add("message", message.toJson());
            param.Add("timestamp", (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000);
            param.Add("environment", environment);
            string ret = callRestful(XingeApp.RESTAPI_CREATEMULTIPUSH, param);

            return(ret);
        }
예제 #7
0
        //推送账号列表,ios设备使用
        public string PushAccountList(List <string> accountList, MessageIOS message, int 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("access_id", this.m_accessId);
            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("timestamp", (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000);
            param.Add("environment", environment);
            string ret = callRestful(XingeApp.RESTAPI_PUSHACCOUNTLIST, param);

            return(ret);
        }