示例#1
0
        private ReceivedResult getReceiveds_common(String msg_ids, string path)
        {
            String          url    = REPORT_HOST_NAME + path + "?msg_ids=" + msg_ids;
            String          auth   = Base64.getBase64Encode(this.appKey + ":" + this.masterSecret);
            ResponseWrapper rsp    = this.sendGet(url, auth, null);
            ReceivedResult  result = new ReceivedResult();
            List <ReceivedResult.Received> list = new List <ReceivedResult.Received>();

            Console.WriteLine("recieve content==" + rsp.responseContent);
            if (rsp.responseCode == System.Net.HttpStatusCode.OK)
            {
                list = (List <ReceivedResult.Received>)JsonTool.JsonToObject(rsp.responseContent, list);
                String content = rsp.responseContent;
            }
            result.ResponseResult = rsp;
            result.ReceivedList   = list;
            return(result);
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.WriteLine("************");
            Console.WriteLine("*****开始发送******");

            //String result;
            String app_key       = "_";
            String master_secret = "_";
            //int sendno = 9;

            HashSet <DeviceEnum> set = new HashSet <DeviceEnum>();

            set.Add(DeviceEnum.Android);
            set.Add(DeviceEnum.IOS);
            JPushClient client = new JPushClient(app_key, master_secret, 0, set, true);

            MessageResult result = null;

            NotificationParams  notifyParams = new NotificationParams();
            CustomMessageParams customParams = new CustomMessageParams();

            //notifyParams.

            //传入json字符串


            String extras = null;


            extras = "{\"ios\":{\"badge\":88, \"sound\":\"happy\"}}";


            //extras中有中文请用HttpUtility.UrlEncode编码
            //System.Web.HttpUtility.UrlEncode(notificationContent, Encoding.UTF8);

            Console.WriteLine("*****发送带tag通知******");

            /**
             *发送类型
             * APP_KEY      通知
             * TAG           TAG
             * ALIAS       ALIAS
             * REGISTRATION_ID  REGISTRATION_ID
             */
            notifyParams.ReceiverType = ReceiverTypeEnum.APP_KEY;

            notifyParams.SendNo = 256;
            //notifyParams.OverrideMsgId = "1";

            result = client.sendNotification("酷派tag111111", notifyParams, extras);
            Console.WriteLine("sendNotification by tag:**返回状态:" + result.getErrorCode().ToString() +
                              "  **返回信息:" + result.getErrorMessage() +
                              "  **Send No.:" + result.getSendNo() +
                              "  msg_id:" + result.getMessageId() +
                              "  频率次数:" + result.getRateLimitQuota() +
                              "  可用频率:" + result.getRateLimitRemaining() +
                              "  重置时间:" + result.getRateLimitReset());



            Console.WriteLine("*****发送带tag消息******");

            //customParams.addPlatform(DeviceEnum.Android);
            customParams.ReceiverType  = ReceiverTypeEnum.TAG;
            customParams.ReceiverValue = "tag_api";

            customParams.SendNo = 256;
            result = client.sendCustomMessage("send custom mess by tag", "tag notify content", customParams, extras);
            Console.WriteLine("sendCustomMessage:**返回状态:" + result.getErrorCode().ToString() +
                              "  **返回信息:" + result.getErrorMessage() +
                              "  **Send No.:" + result.getSendNo() +
                              "  msg_id:" + result.getMessageId() +
                              "  频率次数:" + result.getRateLimitQuota() +
                              "  可用频率:" + result.getRateLimitRemaining() +
                              "  重置时间:" + result.getRateLimitReset());


            Console.WriteLine();

            String         msg_ids        = "1613113584,1229760629,1174658841,1174658641";
            ReceivedResult receivedResult = client.getReceivedApi(msg_ids);

            Console.WriteLine("Report Result:");
            foreach (ReceivedResult.Received re in receivedResult.ReceivedList)
            {
                Console.WriteLine("getReceivedApi************msgid=" + re.msg_id + "  ***andriod received=" + re.android_received + " ***ios received=" + re.ios_apns_sent);
            }
            Console.WriteLine();
        }