吐司通知不起作用

时间:2012-02-02 04:27:45

标签: windows-8 toast microsoft-metro

下面的方法在设置Toast时调用,但在经过一段时间后不显示任何Toast。 Windows 8 Metro应用程序Toast通知需要更多设置

 int scheduledToastCounter = 1;

    public void Set_Future_Toast()
    {

            XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

            XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
            stringElements.Item(0).AppendChild(toastXml.CreateTextNode("Scheduled Toast"));

            DateTimeOffset displayTime = DateTimeOffset.UtcNow.AddSeconds(3);

            ScheduledToastNotification scheduledToast = new ScheduledToastNotification(toastXml, displayTime);
            scheduledToast.Id = "Future_" + this.scheduledToastCounter++;

            ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier();
            notifier.AddToSchedule(scheduledToast);

            int scheduledToastCount = notifier.GetScheduledToastNotifications().Count;
        }

     }

7 个答案:

答案 0 :(得分:14)

您应该在应用包中设置能够为yes的吐司。 enter image description here

答案 1 :(得分:2)

请务必选中应用配置文件中的复选框以启用通知。

答案 2 :(得分:2)

对象通知程序的属性设置告诉您无法显示toast的原因:

0 :已启用,可以显示此应用引发的所有通知。

1 :DisabledForApplication,用户已停用此应用的通知。

2 :DisabledForUser,用户或管理员已在此计算机上禁用此用户的所有通知。

3 :DisabledByGroupPolicy,管理员已通过组策略禁用此计算机上的所有通知。组策略设置会覆盖用户的设置。

4 :DisabledByManifest,此应用尚未在其package.appxmanifest文件中声明自己的toast功能。此设置位于清单的“应用程序UI”页面的“通知”部分下。对于要发送Toast的应用程序,Toa​​st Capable选项必须设置为“Yes”。

http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.notifications.notificationsetting.aspx

答案 3 :(得分:1)

您可以直接从代码页更改Package.appxmanifest:

将ToastCapable添加到VisualElements标记

 <VisualElements  ToastCapable="true">

有时,Package.appxmanifest的屏幕无法选择更改它:

my Package.appxmanifest

答案 4 :(得分:1)

需要为通知设置小图标! enter image description here

答案 5 :(得分:1)

您是否尝试过使应用Toast功能?检查此主题:Toast notification isn't working?

答案 6 :(得分:0)

我遇到的一个有趣的问题是我正在使用图像烤面包。我有一个依赖程序集中的图像与复制到输出目录。调度toast只是默默地失败了。按需吐司因EESFAIL的HRESULT失败(没有其他信息)。当我最终将图像复制到主项目中(带有复制到输出目录)时,它们就开始工作了。

相关问题