public async System.Threading.Tasks.Task <HttpResponseMessage> SendBaiduNativeNotification([Metadata("Connection String")] string connectionString, [Metadata("Hub Name")] string hubName, [Metadata("Message")] string message, [Metadata("Toast Tags")] string tags = null)
        {
            try
            {
                NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString(connectionString, hubName);

                NotificationOutcome result;
                if (!string.IsNullOrEmpty(tags))
                {
                    result = await hub.SendBaiduNativeNotificationAsync(message, tags);
                }
                else
                {
                    result = await hub.SendBaiduNativeNotificationAsync(message);
                }

                return(Request.CreateResponse <NotificationOutcome>(HttpStatusCode.OK, result));
            }
            catch (ConfigurationErrorsException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.BareMessage));
            }
        }
示例#2
0
        public async void SendNotificationAsync(string title, string dsc)
        {
            NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString(defaultFullSharedAccessSignatureSASConnectionString, notificationHubName);
            string message            = "{\"title\":\"" + title + "\",\"description\":\"" + dsc + "\"}";

            await hub.SendBaiduNativeNotificationAsync(message);

            string appleMsg = "{\"aps\":{\"alert\":\"" + dsc + "\"}}";

            await hub.SendAppleNativeNotificationAsync(appleMsg);

            //string appleMsg = "";

            //await hub.SendWindowsNativeNotificationAsync();
        }