Toast通知不起作用?

3
我正在跟随几个示例,在我的应用程序中点击按钮时进行toast通知。 我已经按照以下示例进行了步骤:http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868254.aspx 我没有收到任何错误,但当我运行应用程序时,我没有收到toast通知。 我在这里创建了一个片段:http://codepaste.net/btkzeg
ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01;
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);

XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
toastTextElements[0].AppendChild(toastXml.CreateTextNode("Hello World!"));

XmlNodeList toastImageAttributes = toastXml.GetElementsByTagName("image");

((XmlElement)toastImageAttributes[0]).SetAttribute("src", "ms-appx:///assets/oil.png");
((XmlElement)toastImageAttributes[0]).SetAttribute("alt", "oil graphic");

IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
((XmlElement)toastNode).SetAttribute("duration", "long");

((XmlElement)toastNode).SetAttribute("launch", "{\"type\":\"toast\",\"param1\":\"12345\",\"param2\":\"67890\"}");

ToastNotification toast = new ToastNotification(toastXml);

ToastNotificationManager.CreateToastNotifier().Show(toast);

如果您有建议,请告诉我。

可能是重复的问题:Toast 通知不起作用 - bummi
3个回答

12

我找到了问题所在。我需要将我的应用程序清单设置为Toast Capable。我还注意到它在模拟器模式下无法工作...但在本地机器模式下可以工作。


3
此外,请确保在清单文件(Package.appxmanifest)中设置了“toast capable”。

1
在Package.appxmanifest文件中,ApplicationUI/Toast capable应该是Yes,才能显示我们的Toast通知。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接