Reputation: 1
Hi Guys I have a windows 8.1 tablet application that I want to configure to receive toast notifications. I have done my research and the only references I have found are to configure a windows 8.1 phone app not tablet. Anyway I tried to use the same code but my app is missing the right assembly references
using Microsoft.Phone.Notification;
So my question is how do I configure my tablet to receive toast notifications or is there an alternative assembly reference that I can use instead of the one above to do something similar to what they have at this link. https://msdn.microsoft.com/en-us/library/windows/apps/hh202967(v=vs.105).aspx
Upvotes: 0
Views: 135
Reputation: 21919
Windows Tablets don't run the Windows Phone OS and don't use the Windows Phone Silverlight API.
Both Windows and Windows Phone (8.1) devices run Windows Runtime apps and use the Windows Runtime toast system from the Windows.UI.Notifications namespace.
You'll enable the app to use toasts in the app's manifest.
To send the toast locally you'll get the toast template, update its XML to match what you need, create a ToastNotification object from that XML, then send it with the ToastNotificationManager.
ToastTemplateType toastTemplate = ToastTemplateType.ToastText01;
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
toastTextElements[0].AppendChild(toastXml.CreateTextNode("Hello World!"));
ToastNotification toast = new ToastNotification(toastXml);
ToastNotificationManager.CreateToastNotifier().Show(toast);
To push a toast remotely you'll set up the XML and then send it to the Windows Notification Server (WNS) from your server.
Toast notification overview (Windows Runtime apps)
Quickstart: Sending a toast notification (XAML)
Upvotes: 1