C#阿里云移动推送列表

  C#阿里云移动推送列表

这个就在上期随笔的基础之上,加一个 函数就行了。   简单的。

 

附上源码:一下代码只要把参数改一下就可以了,中间几个参数 可以灵活修改

        /// <summary>
        /// 获取移动消息列表
        /// </summary>
        public static void GetPushList()
        {
            IClientProfile clientProfile = DefaultProfile.GetProfile("cn-hangzhou", AliyunConfig.AccessId, AliyunConfig.AccessSecret);
            DefaultAcsClient client = new DefaultAcsClient(clientProfile);
            ListPushRecordsRequest request = new ListPushRecordsRequest();
            request.AppKey = AliyunConfig.AppKeyIOS;// 设备区分
            request.PushType = "NOTICE";//推送区分
            String startTime = DateTime.UtcNow.AddDays(-7).ToString("yyyy-MM-ddTHH\\:mm\\:ssZ"); //查询近期天的数据
            String endTime = DateTime.UtcNow.ToString("yyyy-MM-ddTHH\\:mm\\:ssZ");
            request.StartTime = startTime;
            request.EndTime = endTime;
            request.Page = 1;
            request.PageSize = 10;
            try
            {
                ListPushRecordsResponse response = client.GetAcsResponse(request);
                Console.WriteLine("RequestId:" + response.RequestId);
                int? count = response.Total;

                foreach (ListPushRecordsResponse.ListPushRecords_PushMessageInfo stat in response.PushMessageInfos)
                {
                    Console.WriteLine("MessageId:" + stat.MessageId);
                    Console.WriteLine("Type:" + stat.Type);
                    Console.WriteLine("DeviceType:" + stat.DeviceType);
                    Console.WriteLine("PushTime:" + stat.PushTime);
                    Console.WriteLine("Title:" + stat.Title);
                    Console.WriteLine("Body:" + stat.Body);
                }
                Console.ReadLine();
            }
            catch (ServerException ex)
            {
                Console.WriteLine(ex.ErrorCode);
                Console.WriteLine(ex.ErrorMessage);
                Console.ReadLine();
            }
            catch (ClientException ex)
            {
                Console.WriteLine(ex.ErrorCode);
                Console.WriteLine(ex.ErrorMessage);
                Console.ReadLine();
            }
        }

 

posted on 2018-09-11 14:50  o笨小孩o  阅读(293)  评论(0编辑  收藏  举报