예제 #1
0
        private async Task SendNotification(List <string> tags, string message)
        {
            try
            {
                do
                {
                    if (tags.Count <= 20)
                    {
                        await hub.SendGcmNativeNotificationAsync("{ \"data\" : {\"Message\":\"" + message + "\"}}", tags);

                        tags.Clear();
                    }
                    else
                    {
                        var tags20 = new List <string>();
                        for (int i = 0; i < 20; i++)
                        {
                            tags20.Add(tags[i]);
                        }

                        tags.RemoveRange(0, 20);
                        await hub.SendGcmNativeNotificationAsync("{ \"data\" : {\"Message\":\"" + message + "\"}}", tags20);
                    }
                } while (tags.Count > 0);
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }
        public async Task <NotificationOutcome> SendNotification(string payload, string tag)
        {
            try
            {
                var response = await _hubClient.SendGcmNativeNotificationAsync(payload, tag);

                return(response);
            }
            catch (Exception e)
            {
                Log.Error("Send Notification error {@error}", e.Message);
                throw e;
            }
        }
예제 #3
0
        /// <summary>
        /// Send notification to Android devices
        /// </summary>
        /// <param name="tag"> If tag is present the notification will go only to the device(s) that have this tag in the Notification hub registration</param>
        /// <param name="message">Notification Message</param>
        public async Task <bool> SendGcmNotificationAsync(string tag, string message)
        {
            try
            {
                NotificationOutcome result = await myClient.SendGcmNativeNotificationAsync("{ \"data\" : {\"message\":\"" + message + "\"}}", tag);

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(false);
                // TODO log error
            }
        }
예제 #4
0
        public async Task <IHttpActionResult> Send([FromBody] Message message)
        {
            try
            {
                var registrations = await hub.GetRegistrationsByTagAsync(message.RecipientId, 100);

                NotificationOutcome outcome;

                if (registrations.Any(r => r is GcmRegistrationDescription))
                {
                    var notif = "{ \"data\" : {\"subject\":\"Message from " + message.From + "\", \"message\":\"" + message.Body + "\"}}";
                    outcome = await hub.SendGcmNativeNotificationAsync(notif, message.RecipientId);

                    return(Ok(outcome));
                }

                if (registrations.Any(r => r is AppleRegistrationDescription))
                {
                    var notif = "{ \"aps\" : {\"alert\":\"" + message.From + ":" + message.Body + "\", \"subject\":\"Message from " + message.From + "\", \"message\":\"" + message.Body + "\"}}";
                    outcome = await hub.SendAppleNativeNotificationAsync(notif, message.RecipientId);

                    return(Ok(outcome));
                }

                return(NotFound());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #5
0
파일: Ntfy.cs 프로젝트: jimliuxyz/UW
        /// <summary>
        /// 發送訊息到指定tag
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="pns"></param>
        /// <param name="message"></param>
        /// <param name="type">自訂動作</param>
        /// <param name="payload">自訂資料</param>
        private async Task sendToTag(string tag, PNS pns, string message, string type = null, object payload = null)
        {
            var notif  = "";
            var custom = new {
                type    = type,
                payload = payload
            };
            var custom_json = "\"custom\" : " + Newtonsoft.Json.JsonConvert.SerializeObject(custom);

            switch (pns)
            {
            case PNS.apns:
                notif = "{ \"aps\" : {\"alert\":\"" + message + "\"}, " + custom_json + "}";
                await hub.SendAppleNativeNotificationAsync(notif, new string[] { tag });

                break;

            case PNS.gcm:
                notif = "{ \"data\" : {\"message\":\"" + message + "\"}, " + custom_json + "}";
                await hub.SendGcmNativeNotificationAsync(notif, new string[] { tag });

                break;

            default:
                break;
            }
        }
예제 #6
0
        public async Task <bool> SendNotificationAsync(string message, string to_tag)
        {
            string[] userTag = new string[1];
            userTag[0] = to_tag;

            string defaultFullSharedAccessSignature = "Endpoint=sb://hbscr13.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=hS+NQ17Qu8CwNBVxzSWVY3ORJ4nK2lMNTFENbFc5Vck=";
            string hubName = "hbPedidos";

            _hub = NotificationHubClient.CreateClientFromConnectionString(defaultFullSharedAccessSignature, hubName);

            NotificationOutcome outcome = null;

            // Android
            var notif = "{ \"data\" : {\"message\":\"" + message + "\"}}";

            outcome = await _hub.SendGcmNativeNotificationAsync(notif, userTag);

            if (outcome != null)
            {
                if (!((outcome.State == NotificationOutcomeState.Abandoned) ||
                      (outcome.State == NotificationOutcomeState.Unknown)))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #7
0
        public async Task <IHttpActionResult> Enviar(ChatViewModel messageInfo)
        {
            string[] userTag = new string[2];
            userTag[0] = "username:"******"from:" + messageInfo.From;

            Microsoft.Azure.NotificationHubs.NotificationOutcome outcome = null;
            HttpStatusCode ret = HttpStatusCode.InternalServerError;

            var notif = "{ \"data\" : {\"message\":\"" + "De " + messageInfo.From + ": " + messageInfo.Message + "\"}}";

            outcome = await _hubClient.SendGcmNativeNotificationAsync(notif, userTag);

            if (outcome != null)
            {
                if (!((outcome.State == Microsoft.Azure.NotificationHubs.NotificationOutcomeState.Abandoned) ||
                      (outcome.State == Microsoft.Azure.NotificationHubs.NotificationOutcomeState.Unknown)))
                {
                    ret = HttpStatusCode.OK;
                }
            }

            var result = new { sucess = true, message = ret == HttpStatusCode.OK ? "Mensagem enviada com sucesso." : "Ocorreu algum problema ao tentar enviar a mensagem." };

            return(Ok(result));
        }
예제 #8
0
        public async Task <string> TestNotificationRegistration()
        {
            //await NotifyByTag("This is message", "all");
            HttpConfiguration           config   = this.Configuration;
            MobileAppSettingsDictionary settings = this.Configuration.GetMobileAppSettingsProvider().GetMobileAppSettings();

            string notificationHubName       = settings.NotificationHubName;
            string notificationHubConnection = settings.Connections[MobileAppSettingsKeys.NotificationHubConnectionString].ConnectionString;

            NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString(notificationHubConnection, notificationHubName, true);


            //var x = await hub.GetAllRegistrationsAsync(10);


            Dictionary <string, string> templateParams = new Dictionary <string, string>();

            templateParams["messageParam"] = "Notification OK.";

            string gcmpl = @"{""data"":{""message"":""Notification Hub test notification"", ""title"":""ConnectiveSport Notification""}}";

            var outcome = await hub.SendGcmNativeNotificationAsync(gcmpl, new List <String> {
                "all"
            });

            //var outcome = await hub.SendTemplateNotificationAsync(templateParams, new List<String> { "falcons","all" });

            return("excuted");// 'outcome.State.ToString();
        }
예제 #9
0
        //Sending notification to GCM (Google Chrome Applicaiton)
        private static async void PushGCMNotificationAsync(string incommingMessage)
        {
            try
            {
                string NotificationHubConnectionString = CloudConfigurationManager.GetSetting("NotificationHubConnectionString");
                string NotificationHubName             = CloudConfigurationManager.GetSetting("NotificationHubName");
                NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString(NotificationHubConnectionString, NotificationHubName);

                dynamic data           = new JsonReader().Read(incommingMessage);
                string  publishMessage = string.Empty;

                foreach (var item in data)
                {
                    if (item.Key == "message")
                    {
                        publishMessage = item.Value;
                    }
                }

                String message = string.Concat("{\"data\":{\"Message\":\"", publishMessage, "\"}}");
                await hub.SendGcmNativeNotificationAsync(message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #10
0
        public static async void SendTemplateNotificationAsync2()
        {
            // Get the Notification Hubs credentials for the Mobile App.
            string notificationHubName       = hubName;
            string notificationHubConnection = connectionString;

            // Create a new Notification Hub client.
            NotificationHubClient hub = NotificationHubClient
                                        .CreateClientFromConnectionString(notificationHubConnection, notificationHubName);

            // Android payload
            var androidNotificationPayload = "{ \"data\" : {\"message\":\"" + "Notification Hub test notification RUTU" + "\"}}";

            try
            {
                // Send the push notification and log the results.
                var result = await hub.SendGcmNativeNotificationAsync(androidNotificationPayload);

                // Write the success result to the logs.
                // config.Services.GetTraceWriter().Info(result.State.ToString());
            }
            catch (System.Exception ex)
            {
                // Write the failure result to the logs.
                //  //config.Services.GetTraceWriter()
                ///.Error(ex.Message, null, "Push.SendAsync Error");
            }
        }
예제 #11
0
        public static async Task Run([ServiceBusTrigger("notification", AccessRights.Manage, Connection = "ServiceBusConnection")] string myQueueItem, TraceWriter log)
        {
            string str = "Face Detect Notification: Calculate Face Detect Notification";

            try
            {
                log.Info($"C# Queue trigger function processed: {myQueueItem}");

                // In this example the queue item is a new user to be processed in the form of a JSON string with
                // a "name" value.
                //
                // The JSON format for a native GCM notification is ...
                // { "data": { "message": "notification message" }}
                NotificationHubClient hub = NotificationHubClient
                                            .CreateClientFromConnectionString(ConfigurationManager.AppSettings["NotificationConnection"], ConfigurationManager.AppSettings["NotificationHub"]);

                string gcmNotificationPayload = "{\"data\": { \"message\": " + myQueueItem + " }} ";
                log.Info($"{gcmNotificationPayload}");
                await hub.SendGcmNativeNotificationAsync(gcmNotificationPayload);
            }
            catch (Exception exception)
            {
                log.Error($"Failed in {str}: {exception.Message}", exception, null);
            }
        }
예제 #12
0
    protected void btnSend_Click(object sender, EventArgs e)
    {
        string notificationHubName       = "test";
        string notificationHubConnection =
            "Endpoint=sb://orangejetpack.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=uMJHQThBSc1EsIcMms3PyTasVUW1cwhaAdyZSAHraXU=";

        NotificationHubClient hub = NotificationHubClient
                                    .CreateClientFromConnectionString(notificationHubConnection, notificationHubName);

        var androidNotificationPayload = "{ \"data\" : {\"message\":\"" + TextBox1.Text + "\"}}";

        try
        {
            //var result = await hub.SendGcmNativeNotificationAsync(androidNotificationPayload);
            hub.SendGcmNativeNotificationAsync(androidNotificationPayload)
            .ContinueWith(FailSend, TaskContinuationOptions.OnlyOnFaulted);

            Response.Write("Notification has been send");
        }
        catch (System.Exception ex)
        {
            // Write the failure result to the logs.
            Response.Write("Push.SendAsync Error, " + ex.Message);
        }
    }
예제 #13
0
        private static void SendAndroidNotificationAsync(string subject, string content, NotificationHubClient hub)
        {
            //NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString(NOTIFICATION_HUB_FULL_ACCESS_CONNECTION_STRING, NOTIFICATION_HUB_NAME);
            var alert = "{\"data\":{\"subject\":\"" + subject + "\",\"content\":\"" + content + "\"}}";

            hub.SendGcmNativeNotificationAsync(alert).Wait(500);
        }
예제 #14
0
        private void NotifyUsers(string eventID, CloudStorageAccount storageAccount)
        {
            NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString(connectionStringNotification, hubName);
            WnsHeaderCollection   wnsHeaderCollection = new WnsHeaderCollection();

            wnsHeaderCollection.Add("X-WNS-Type", @"wns/raw");
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
            CloudTable       table       = tableClient.GetTableReference("registeredDevices");

            table.CreateIfNotExists();
            //TableQuery<UserEntity> query = new TableQuery<UserEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "registeredDevices"));

            //List<string> usersTag = new List<string>();
            //List<UserEntity> aa = table.ExecuteQuery(new TableQuery<UserEntity>()).ToList();
            //foreach (UserEntity entity in aa)
            //{
            //    usersTag.Add(entity.RowKey);
            //}
            ////var notif = "{ \"data\" : {\"message\":\"" + "EventId " + eventID + "\"}}";
            ////hub.SendGcmNativeNotificationAsync(notif, usersTag);
            //string a = "8736725417766488658-761683147264243211-3";
            var notif = "{\"data\" : {\"message\":\"" + "event added EventId " + eventID + "\"}}";

            //var notif = "{\"registration_ids\": [\""+ a + "\"], \"data\" : {\"message\":\"" + "event added EventId " + eventID + "\"}}";
            hub.SendGcmNativeNotificationAsync(notif);
        }
예제 #15
0
        public static async Task <bool> SendNotificationAsync(string message, System.Collections.Generic.IEnumerable <string> tags, string to, string tipo, int idCompra, string idDistribuidor)
        {
            try
            {
                hub = NotificationHubClient.CreateClientFromConnectionString(ListenConnectionString, NotificationHubName);

                var notif = ("{\"data\":{\"message\":\"" + message + "\"}}");

                if (to != "" && to != null)
                {
                    notif = ("{\"to\":\"" + to.ToString() +
                             "\",\"data\":" +
                             "{\"message\":\"" + message + "\",\"tipo\":\"" + tipo + "\",\"idCompra\":\"" + idCompra + "\",\"idDistribuidor\":\"" + idDistribuidor + "\"}" +
                             "}");
                }
                await hub.SendGcmNativeNotificationAsync(notif, tags);

                return(true);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);

                return(true);
            }
        }
예제 #16
0
        public static async Task <bool> SendNotificationAsync(string message, string idNotificacao, bool broadcast = false)
        {
            string[] userTag = new string[1];

            // Obs importantíssima: O username tá na primeira parte do id da
            // notificação antes do ":"(dois pontos). Para mandar broadcast é só
            //enviar o username em branco
            userTag[0] = string.Empty;


            string defaultFullSharedAccessSignature = util.configTools.getConfig("hubnotificacao");
            string hubName = util.configTools.getConfig("hubname");
            string handle  = idNotificacao;//hubName;

            NotificationHubClient _hub = NotificationHubClient.CreateClientFromConnectionString(defaultFullSharedAccessSignature, hubName);
            //await _hub.DeleteRegistrationAsync(idNotificacao);

            //Excluindo registros
            var registrations = await _hub.GetRegistrationsByChannelAsync(handle, 100);

            foreach (RegistrationDescription xregistration in registrations)
            {
                try
                {
                    await _hub.DeleteRegistrationAsync(xregistration);
                }
                catch (Exception ex) { string sm = ex.Message; }
            }


            if (!broadcast)
            {
                string to_tag = idNotificacao.Split(':')[0];
                userTag[0] = "username:"******"{ \"data\" : {\"message\":\"" + message + "\"}}";

            outcome = await _hub.SendGcmNativeNotificationAsync(notif, userTag);

            if (outcome != null)
            {
                if (!((outcome.State == NotificationOutcomeState.Abandoned) ||
                      (outcome.State == NotificationOutcomeState.Unknown)))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #17
0
        public async Task <IHttpActionResult> Send(NotificationMessage message)
        {
            var messageString = "{\"data\": {\"message\": \"" + message.Message + "\", \"title\": \"" + message.Title +
                                "\"} }";
            var result = await _notificationHubClient.SendGcmNativeNotificationAsync(messageString, message.Tags);

            return(Ok("Notification has been send successfully."));
        }
예제 #18
0
        public async Task Send(Message message, string ActivityId = "")
        {
            _logger.Information($"ActivityId {ActivityId} :Sending notification {message.id} {message.to}....");
            string msgString = JsonConvert.SerializeObject(message);
            await hub.SendGcmNativeNotificationAsync(msgString);

            _logger.Information($"ActivityId {ActivityId} :Notfication Sent {message.id} {message.to}.");
        }
        public static async Task SendBroadcastNotification(string text)
        {
            var jsonGcm = string.Format("{{\"data\":{{\"message\":\"{0}\"}}}}", text);
            await notitifcationHubClient.SendGcmNativeNotificationAsync(jsonGcm);

            var jsonApns = string.Format("{{\"aps\":{{\"alert\":\" {0}\"}}}}", text);
            await notitifcationHubClient.SendAppleNativeNotificationAsync(jsonApns);
        }
예제 #20
0
        private static async void SendNotificationAsync(string message)
        {
            var tags = new List <string>();

            tags.Add("UserId:[email protected]");
            tags.Add("UserId:[email protected]");
            await hub.SendGcmNativeNotificationAsync(
                "{ \"data\" : {\"Message\":\"" + message + "\"}}", tags);
        }
예제 #21
0
        public IHttpActionResult SendMessage(Poco.Message message)
        {
            if (string.IsNullOrWhiteSpace(message.Sender))
            {
                return(BadRequest("The sender is not valid!"));
            }

            if (string.IsNullOrWhiteSpace(message.Content))
            {
                return(BadRequest("The password is not valid!"));
            }

            try
            {
                using (var ctx = new ChattyDbContext())
                {
                    string email = (this.User as ClaimsPrincipal).FindFirst(ClaimTypes.Email).Value;
                    User   user  = ctx.Users.Single(x => x.Email == email);
                    user.LastActiveDate = DateTime.Now.ToUniversalTime();

                    Message m = new Message {
                        Content = message.Content, Sender = message.Sender, SendDate = DateTime.Now.ToUniversalTime()
                    };
                    ctx.Messages.Add(m);

                    ctx.SaveChanges();

                    _nhclient.SendGcmNativeNotificationAsync(
                        Newtonsoft.Json.JsonConvert.SerializeObject(Push.Android.Make(
                                                                        "New messages",
                                                                        "You have new unread messages!",
                                                                        1,
                                                                        m.MessageId.ToString()
                                                                        )), String.Concat("!", user.Email));

                    _nhclient.SendAppleNativeNotificationAsync(
                        Newtonsoft.Json.JsonConvert.SerializeObject(Push.iOS.Make(
                                                                        "New messages",
                                                                        "You have new unread messages!",
                                                                        1,
                                                                        m.MessageId.ToString()
                                                                        )), String.Concat("!", user.Email));

                    return(Ok(Dto.Wrap(new Poco.Message
                    {
                        MessageId = m.MessageId,
                        Content = m.Content,
                        Sender = m.Sender,
                        SendDate = m.SendDate
                    })));
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
예제 #22
0
        private static async void SendNotificationAsync()
        {
            NotificationHubClient hub = NotificationHubClient
                                        .CreateClientFromConnectionString("Endpoint=sb://kdnotificationhub-ns.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=Yv7Xpeovd/Suldrl3KBWy7sLk2fzbgOqfSF8DDltuG4=", "kdnotificationhub");

            String message = "{\"data\":{\"message\":\"Hello Chrome from Azure Notification Hubs\"}}";

            await hub.SendGcmNativeNotificationAsync(message);
        }
예제 #23
0
        private static async void SendNotificationAsync(string message)
        {
            var tags = new List <string>();

            tags.Add("userId:1");
            tags.Add("userId:2");
            tags.Add("userId:3");
            await hub.SendGcmNativeNotificationAsync("{ \"data\" : {\"Message\":\"" + message + "\"}}", tags);
        }
예제 #24
0
        private static async Task SendAndroidNotificationAsync(string msg)
        {
            NotificationHubClient hub = NotificationHubClient
                                        .CreateClientFromConnectionString(nhConnectionString, hubName);

            Newtonsoft.Json.Linq.JObject o = JsonConvert.DeserializeObject(msg) as Newtonsoft.Json.Linq.JObject;
            var toast   = "{data:{message:'{device} alert at {time}'}}".Replace("{device}", (string)o["deviceid"]).Replace("{time}", (string)o["time"]);
            var results = await hub.SendGcmNativeNotificationAsync(toast);
        }
예제 #25
0
        private static async void SendNotificationAsync()
        {
            string connectionString    = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];
            string notificationHubPath = ConfigurationManager.AppSettings["Microsoft.ServiceBus.NotificationHubPath"];

            NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString(connectionString, notificationHubPath);
            //var toast = @"<toast><visual><binding template=""ToastText01""><text id=""1"">Hello from a .NET App!</text></binding></visual></toast>";
            //await hub.SendWindowsNativeNotificationAsync(toast);
            await hub.SendGcmNativeNotificationAsync("{ \"data\" : { \"message\" : \"Hello from Windows Azure!\" } }");
        }
예제 #26
0
        private NotificationOutcome SendGCM(PushMessage msg)
        {
            var obj = new GCMMessage.RootObject();

            obj.data.Add("title", msg.Title);
            obj.data.Add("message", msg.Message);

            var json = JsonConvert.SerializeObject(obj);

            return(hub.SendGcmNativeNotificationAsync(json, msg.Tag).Result);
        }
        public async Task <IActionResult> SendNotification([FromBody] NotificationCreationModel notificationReq)
        {
            try
            {
                var jsonNotification = JsonConvert.SerializeObject(notificationReq);

                NotificationOutcome response = (notificationReq.Tags != null && notificationReq.Tags.Count > 0) ?
                                               await _hubClient.SendGcmNativeNotificationAsync("{\"data\":{\"message\":" + jsonNotification + "}}", notificationReq.Tags) :
                                               await _hubClient.SendGcmNativeNotificationAsync("{\"data\":{\"message\":" + jsonNotification + "}}");

                NotificationOutcome responseApple = (notificationReq.Tags != null && notificationReq.Tags.Count > 0) ?
                                                    await _hubClient.SendAppleNativeNotificationAsync("{\"aps\":{\"alert\":\"" + notificationReq.Title + ": " + notificationReq.NotificationText + "\"}}", notificationReq.Tags) :
                                                    await _hubClient.SendAppleNativeNotificationAsync("{\"aps\":{\"alert\":\"" + notificationReq.Title + ": " + notificationReq.NotificationText + "\"}}");

                var outcomes = new List <NotificationOutcome>()
                {
                    response, responseApple
                };
                NotificationModel model = null;

                if (response.Results != null && responseApple.Results != null)
                {
                    notificationReq.Status = 1;
                    model = await _notificationDataManager.CreateNotification(notificationReq);

                    return(Ok(model));
                }
                else
                {
                    notificationReq.Status = 0;
                    model = await _notificationDataManager.CreateNotification(notificationReq);

                    return(Ok(model));
                }
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status502BadGateway, e.Message));
            }
        }
예제 #28
0
        public async Task <ActionResult> Create([Bind(Include = "NewsId,Title,Image,Description")] News news)
        {
            if (ModelState.IsValid)
            {
                db.Newses.Add(news);
                db.SaveChanges();
                var messageString = "{\"data\": {\"message\": \"New News Was Added\"} }";
                var result        = await _notificationHubClient.SendGcmNativeNotificationAsync(messageString);

                return(RedirectToAction("Index"));
            }
            return(View(news));
        }
예제 #29
0
        private static async void SendNotificationAsync(string message)
        {
            var tags = new List <string>();

            tags.Add("userId:1");
            tags.Add("userId:2");
            tags.Add("userId:3");
            tags.Add("userId:4");
            //a todo el mundo
            // await hub.SendGcmNativeNotificationAsync("{ \"data\" : {\"Message\":\"" + message + "\"}}");
            //a los que cumplen el tag
            await _hub.SendGcmNativeNotificationAsync("{ \"data\" : {\"Message\":\"" + message + "\"}}", tags);
        }
예제 #30
0
 public async Task sendGCMNotification(string message, IEnumerable <string> tags)
 {
     try
     {
         // Define an Android notification.
         var notification = "{\"data\":{\"msg\":\"" + message + "\"}}";
         await hub.SendGcmNativeNotificationAsync(notification, tags);
     }
     catch (Exception ex)
     {
         Trace.TraceError("Error while sending Google notification: " + ex.Message);
     }
 }