Ejemplo n.º 1
0
        public void XGTestSingleDevice()
        {
            QQXGProvider            qqxg = new QQXGProvider();
            XGPushSingleDeviceParam xgp  = new XGPushSingleDeviceParam();

            xgp.Timestamp  = null;
            xgp.Valid_time = 600; //600;
            xgp.Sign       = null;
            //============测试DEMO==============
            xgp.Access_id = 2100025233;
            //xgp.Access_Key = "ARQ4CB14Q92X";
            xgp.Secret_Key = "6ae193c85570ad1cc8fc9540560093b1";
            //============测试DEMO==============
            //xgp.Access_id = 2100025346;
            //xgp.Access_Key = "AUP1I5W741WJ";
            //xgp.Secret_Key = "f2391810bc98c0d7435ec7c96b8f524f";
            xgp.Message_type = 1;
            xgp.Message      = new NotifyMessage()
            {
                Title   = "XGTestSingleDevice",
                Content = "XGTestSingleDevice",
                Vibrate = 1
            };
            xgp.Device_token = "ef8d1c5b866652d14e62bbee2aac3b28b7ed2bf9";
            //POSTopenapi.xg.qq.com/v2/push/all_deviceaccess_id=2100025233timestamp=1399859926valid_time=6006ae193c85570ad1cc8fc9540560093b1
            XGResult <string> a = qqxg.PushSingleDevice(xgp);
        }
Ejemplo n.º 2
0
        //public XGResult<TResult> PushMethod<TParma, TResult>(XGMethod method, TParma parm)
        //    where TParma : XGPushParamBase
        //{
        //    XGResult<TResult> result = null;
        //    switch (method)
        //    {
        //        case XGMethod.single_device:
        //            break;
        //        case XGMethod.single_account:
        //            break;
        //        case XGMethod.all_device:
        //            result = PushAllDevices(parm as XGPushAllDeviceParam);
        //            break;
        //        case XGMethod.tags_device:
        //            break;
        //        case XGMethod.get_msg_status:
        //            break;
        //        case XGMethod.get_app_device_num:
        //            break;
        //        case XGMethod.query_app_tags:
        //            break;
        //        case XGMethod.cancel_timing_task:
        //            break;
        //        default:
        //            break;
        //    }

        //    return result;
        //}


        /// <summary>
        /// PUSH消息给单个设备
        /// </summary>
        /// <param name="sdParm"></param>
        /// <returns></returns>
        public XGResult <string> PushSingleDevice(XGPushSingleDeviceParam sdParm)
        {
            if (string.IsNullOrEmpty(sdParm.Device_token))
            {
                throw new ArgumentException("sdParm.Device_token参数不能为空!");
            }
            ParamBaseValidata(sdParm);
            PushParamBaseValidata(sdParm);
            ParamBaseCreate(sdParm, XGMethod.single_device);

            string pushSingleDeviceUrl = string.Format("{0}/{1}", apiFullUrl, XGMethod.single_device.ToString());
            string postData            = CreateXGParamPostStr <XGPushSingleDeviceParam>(sdParm, "&");

            System.Diagnostics.Trace.Write("\r\n===postData的值:" + postData);

            string result = httpClient.Post(pushSingleDeviceUrl, postData);

            System.Diagnostics.Trace.Write("\r\n===返回result的值:" + result);
            return(JsonHelper.FromJson <XGResult <string> >(result));
        }