public async static void CreateNotification(string textMessage) { string str_message = string.Empty; str_message = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<wp:Notification xmlns:wp=\"WPNotification\">" + "<wp:Toast>" + "<wp:Text1>" + textMessage + "</wp:Text1>" + "</wp:Toast> " + "</wp:Notification>"; MpnsPushMessage message = new MpnsPushMessage(new Toast()); message.XmlPayload = str_message; try { var result = await Services.Push.SendAsync(message); Services.Log.Info(result.State.ToString()); } catch (System.Exception ex) { Services.Log.Error(ex.Message, null, "Push.SendAsync Error"); } }
public static async void SendMicrosoftPush(ApiServices service, Toast toastMessage) { MpnsPushMessage microsoftPush = new MpnsPushMessage(toastMessage); //string windowsToastMsg = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?><wp:Notification xmlns:wp=\"WPNotification\"><wp:Toast><wp:Text1>{0}</wp:Text1></wp:Toast></wp:Notification>", message); //microsoftPush.XmlPayload = windowsToastMsg; //PushClient teste = new PushClient() SendPush(service, microsoftPush); }
/// <summary> /// Gets the MPNS message. /// </summary> /// <param name="message">The message.</param> /// <returns>IPushMessage.</returns> public static IPushMessage GetMPNSMessage(string message) { var toast = new Toast { Text1 = "Notification Hubs Sample", Text2 = message }; var mpnsPushMessage = new MpnsPushMessage(toast); 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 Hubs Sample"), new XElement(wp + "Text2", message)))); mpnsPushMessage.XmlPayload = string.Concat(doc.Declaration, doc.ToString(SaveOptions.DisableFormatting)); return(mpnsPushMessage); }