吐司通知不起作用? [英] Toast notification isn't working?

查看:52
本文介绍了吐司通知不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击应用程序中的按钮时,我将按照以下示例进行敬酒通知.我逐步完成了以下示例: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868254.aspx

I'm following several examples to do a toast notification when I click a button in my app. I stepped through the following example: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868254.aspx

我没有收到任何错误,但是当我运行该应用程序时,我没有得到吐司通知.我在此处创建了一个代码段: http://codepaste.net/btkzeg

I'm not getting any errors but when I run the application I don't get the toast notification. I have created a snippet here: 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);

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

If you have suggestions please let me know.

推荐答案

我发现了问题所在.我需要将我的应用清单设置为Toast Capable.我还注意到它在模拟器模式下不起作用...但是在本地计算机模式下它起作用.

I figured out the issue. I needed to set my app manifest to Toast Capable. I also noticed it doesn't work in simulator mode... But in Local Machine mode it worked.

这篇关于吐司通知不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆