Exemplo n.º 1
0
        public async Task SendConditionMessage()
        {
            var app = AGConnectApp.Create(new AppOptions()
            {
                ClientId     = "11111111",
                ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
            });

            var msg = AGConnectMessaging.GetMessaging(app);

            await msg.SendAsync(new Message()
            {
                Notification = new Notification()
                {
                    Title = "Test Message",
                    Body  = "Detail Message",
                },
                Android = new AndroidConfig()
                {
                    Notification = new AndroidNotification()
                    {
                        ClickAction = ClickAction.OpenUrl("http://example.com")
                    }
                },
                Token = new string[] { "yyyyyyyyyyyyyyyyyy" }
            });
        }
Exemplo n.º 2
0
 public static void GlobalInit()
 {
     if (!Initialized)
     {
         Initialized = true;
         AGConnectApp.Create(TestUtils.ReadOptionsFromDisk());
     }
 }
Exemplo n.º 3
0
        public Example(ITestOutputHelper logger)
        {
            Logger = logger;

            AGConnectApp.Create(new AppOptions()
            {
                ClientId     = "your client id",
                ClientSecret = "your cliient secret",
            });
        }
        /// <summary>
        /// Returns the messaging instance for the specified app.
        /// </summary>
        /// <returns>The <see cref="AGConnectMessaging"/> instance associated with the specified
        /// app.</returns>
        /// <exception cref="System.ArgumentNullException">If the app argument is null.</exception>
        /// <param name="app">An app instance.</param>
        internal static AGConnectMessaging GetMessaging(AGConnectApp app)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            return(app.GetOrInit(typeof(AGConnectMessaging).Name, () =>
            {
                return new AGConnectMessaging(app);
            }));
        }
Exemplo n.º 5
0
        public async Task GetTopicList()
        {
            var app = AGConnectApp.Create(new AppOptions()
            {
                ClientId     = "11111111",
                ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
            });

            var msg   = AGConnectMessaging.GetMessaging(app);
            var token = "sdjlfjiwekfnskdjfksdfjskdfjsdf";
            TopicListResponse resp = await msg.GetTopicListAsync(token);
        }
Exemplo n.º 6
0
        public async void PushHuaWeiInfoAsync()
        {
            try
            {
                if (app == null)
                {
                    app = AGConnectApp.DefaultInstance;
                    if (app == null)
                    {
                        app = AGConnectApp.Create(new AppOptions());
                    }
                }

                string strResult = await AGConnectMessaging.DefaultInstance.SendAsync(new Message()
                {
                    Android = new AndroidConfig()
                    {
                        Notification = new AndroidNotification()
                        {
                            Title        = "报事工单提醒",
                            Body         = model.Message,
                            ClickAction  = ClickAction.OpenApp(),
                            DefaultSound = true
                        }
                    },
                    Token = model.Audience.Objects.ToList()
                            //Token = new List<string>() { "AQAAAACy0W9KAACT8pBDiwO3pU89GoxbUJTAgEYju39uxw3kXNoqRAVz6gSLL17DbLFk8TMg51OS_x7UHfMPl7Oso79gywwxm8FFcPPYSF-I9loMGw" }
                });

                var Message = new
                {
                    title = "报事工单提醒",
                    body  = model.Message
                };

                string data = JsonConvert.SerializeObject(Message);
                strResult = await AGConnectMessaging.DefaultInstance.SendAsync(new Message()
                {
                    Android = new AndroidConfig()
                    {
                        Data = data
                    },
                    Token = model.Audience.Objects.ToList()
                            //Token = new List<string>() { "AQAAAACy0W9KAACT8pBDiwO3pU89GoxbUJTAgEYju39uxw3kXNoqRAVz6gSLL17DbLFk8TMg51OS_x7UHfMPl7Oso79gywwxm8FFcPPYSF-I9loMGw" }
                });
            }
            catch (Exception eex)
            {
                string str = eex.Message;
            }
        }
Exemplo n.º 7
0
        public async Task SubscribeTopic()
        {
            var app = AGConnectApp.Create(new AppOptions()
            {
                ClientId     = "11111111",
                ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
            });

            var msg    = AGConnectMessaging.GetMessaging(app);
            var tokens = new List <string>()
            {
                "sdjlfjiwekfnskdjfksdfjskdfjsdf"
            };
            var topic = "News";
            await msg.SubscribeToTopicAsync(tokens.AsReadOnly(), topic);
        }
Exemplo n.º 8
0
        public async Task SendTopicMessage()
        {
            var app = AGConnectApp.Create(new AppOptions()
            {
                ClientId     = "11111111",
                ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
            });

            var msg = AGConnectMessaging.GetMessaging(app);

            await msg.SendAsync(new Message()
            {
                Notification = new Notification()
                {
                    Title = "Test Message",
                    Body  = "Detail Message"
                },
                Topic = "News",
                Token = new string[] { "yyyyyyyyyyyyyyyyyy" }
            });
        }
 private AGConnectMessaging(AGConnectApp app)
 {
     this.messagingClient = new AGConnectMessagingClient(app.Options);
 }