[英]Unexpected behaviours in toast notification from desktop app in Windows 10
I used the toast notifications for desktop app since Windows 8.1 but with the new action center in Windows 10, I am experiencing some unexpected behaviours. 自Windows 8.1以来,我一直在为台式机应用程序使用Toast通知,但是随着Windows 10中新的操作中心的使用,我遇到了一些意外行为。
When the user do nothing with the toast, it simply disappear without going to the action center ( ToastNotification.Dismissed
is ToastDismissalReason.TimedOut
). 当用户对吐司不做任何事情时,它只是消失而无需前往动作中心(
ToastNotification.Dismissed
是ToastDismissalReason.TimedOut
)。 I don't know if it related to the fact that I use it in a win32 app but the same toast in a Windows Universal App goes to the action center when it timed out. 我不知道它是否与我在Win32应用程序中使用它有关,但是与Windows通用应用程序中的同一个敬酒在超时时会转到操作中心。
One thing to note is that I have not registered an AppUserModelID for my win32 app like it was needed in W8.1, it seems to not be mandatory anymore. 需要注意的一件事是,我没有像W8.1中那样为我的win32应用程序注册AppUserModelID ,它似乎不再是必需的。 I still tested with a registered id, and I had the same popblem.
我仍然使用注册的ID进行测试,并且出现了同样的问题。
So, how can i prevent the toast from not going in the action center when it timed out ? 因此,如何防止吐司超时时不在操作中心进食?
Here is a minimalist code (console app) that reproduces the issue : 这是重现此问题的极简代码(控制台应用程序):
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
namespace ToastDesktop
{
internal class Program
{
/// Add in the .csproj in the <PropertyGroup/> where <TargetFrameworkVersion/> is:
/// <TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
///
/// Reference to add :
/// - Windows.UI
/// - Windows.Data
private static void Main(string[] args)
{
string xml = $@"
<toast>
<visual>
<binding template='ToastGeneric'>
<text>Some title</text>
<text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</text>
</binding>
</visual>
</toast>";
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
ToastNotification toast = new ToastNotification(doc);
toast.Tag = "tag";
toast.Group = "group";
ToastNotificationManager.CreateToastNotifier("ToastDesktop").Show(toast);
}
}
}
Thanks for your help. 谢谢你的帮助。
Edit : I posted this bug on the msdn blog post that cover the subject and I got the confirmation that it should remain in the action center when timed out and that it might be a bug. 编辑:我在涵盖该主题的msdn博客文章上发布了此错误,并且我确认超时后该错误应保留在操作中心中,并且可能是错误。
Win32应用程序需要设置一个COM服务器,以使吐司持续存在于Action Center中: http : //blogs.msdn.com/b/tiles_and_toasts/archive/2015/10/15/quickstart-handling-toast-activations-from -win32-apps-in-windows-10.aspx
An alternative to the COM method is to set a registry key for your app. COM方法的替代方法是为您的应用设置注册表项 。 Replace
irssi
with ToastDesktop
in your case. 在您的情况下,将
irssi
替换为ToastDesktop
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.