C# .NET移动开发之消息推送

准备工作:


1.获取极光AppKey

2.安装smobiler


推送功能开始:

1.创建smobilerApplication

2.在Application中引用极光推送的dll,下载链接 点击打开链接

3.在发送消息按钮事件上写下如下代码:

 public static JPushClient _Client = new JPushClient(app_key,masterSecret);//对应极光应用中的app_key和masterSecret
        private void btnPush_Press(object sender, EventArgs e)
        {


            PushPayload pushPayload = new PushPayload()
            {
                Platform = "android",
                //Audience = "all",
                Audience = new Audience()
                {
                    Alias = new List<string>
                    {
                        "test"
                    }
                },
                Notification = new Notification()
                {
                    Alert = "hello jpush",
                    Android = new Android()
                    {
                        Alert = "您的小树苗又长大了一点!",
                        Title = "新消息"
                    },
                    IOS = new IOS()
                    {
                        Alert = "ios alert",
                        Badge = "+1"
                    }
                },
                Message = new Message()
                {
                    Title = "message title",
                    Content = "您有新的消息,请查看",
                    Extras = new Dictionary<string, string>()
                    {
                        ["key1"] = "value1"
                    }
                }
            };
            _Client.SendPush(pushPayload);
        }
4.效果:




猜你喜欢

转载自blog.csdn.net/Rabbit199077/article/details/79012868