我可以配置我的Windows 8.1 TABLET应用程序来接收Toast通知

时间:2015-03-26 09:26:13

标签: c# xaml push-notification windows-store-apps windows-8.1

嗨大家我有一个Windows 8.1平板电脑应用程序,我想配置接收Toast通知。我做了我的研究,我发现的唯一参考是配置Windows 8.1手机应用程序而不是平板电脑。无论如何,我试图使用相同的代码,但我的应用程序缺少正确的程序集引用

using Microsoft.Phone.Notification;

所以我的问题是如何配置我的平板电脑以接收Toast通知,或者是否有一个替代的程序集引用,我可以使用它而不是上面的那个来做类似于它在此链接上的内容。 https://msdn.microsoft.com/en-us/library/windows/apps/hh202967(v=vs.105).aspx

1 个答案:

答案 0 :(得分:1)

Windows平板电脑不会运行Windows Phone操作系统,也不会使用Windows Phone Silverlight API。

Windows和Windows Phone(8.1)设备都运行Windows运行时应用程序,并使用Windows.UI.Notifications命名空间中的Windows运行时Toast系统。

您可以让应用在应用的清单中使用祝酒词。

要在本地发送Toast,您将获取Toast模板,更新其XML以匹配您需要的内容,从该XML创建ToastNotification对象,然后使用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);

要远程推送Toast,您可以设置XML,然后从服务器将其发送到Windows Notification Server(WNS)。

Toast notification overview (Windows Runtime apps)

Quickstart: Sending a toast notification (XAML)

Sending notifications