zoukankan      html  css  js  c++  java
  • 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();
                }
            }
  • 相关阅读:
    C#中 File,Directory,FileInfo,DirectoryInfo区别与应用
    C#中设置开机自动运行和关机
    C# 线程手册 第三章 使用线程 小心死锁
    C# WinForm判断Win7下是否是管理员身份运行
    C#应用MemoryStream提高File读取速度
    CodeforcesDouble Profiles
    SRM533 D1 L1
    SRM532 D1 L2
    SRM533 D2 L3
    次小生成树 | 割点 | 割边
  • 原文地址:https://www.cnblogs.com/longm/p/9627624.html
Copyright © 2011-2022 走看看