Exemplo n.º 1
0
        public void SendSampleToastToAllClients()
        {
            foreach (var subscriber in _registrator.ListAllSubscribers())
            {
                var toast = new ToastNotification(subscriber.UniqueId)
                                {
                                    Title = "Hello World!",
                                    Body = "This is a sample Toast..."
                                };

                _notificationQueue.EnqueueItem(toast);
            }
        }
Exemplo n.º 2
0
 private NotificationResponse SendToastNotification(string subscriptionUri, ToastNotification notification)
 {
     XNamespace wp = "WPNotification";
     XDocument doc = new XDocument(new XDeclaration("1.0", "utf-8", null),
         new XElement(wp + "Notification", new XAttribute(XNamespace.Xmlns + "wp", "WPNotification"),
             new XElement(wp + "Toast",
                 new XElement(wp + "Text1",
                     notification.Title),
                 new XElement(wp + "Text2",
                     notification.Body)
                 ))
         );
     var payload = doc.Declaration + doc.ToString(SaveOptions.DisableFormatting);
     var notificationMessage = System.Text.Encoding.UTF8.GetBytes(payload);
     return SendRequest(subscriptionUri, notificationMessage, NotificationKind.Toast);
 }