从桌面应用程序使用 Windows 8 Toast 通知 [英] Use Windows 8 toast notification from desktop app

查看:46
本文介绍了从桌面应用程序使用 Windows 8 Toast 通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个桌面应用程序,它是一个用于 Windows 的简单 .exe.

I developed a desktop app, which is a simple .exe for Windows.

它在 Windows 8 上运行良好.

It works fine on Windows 8.

我现在尝试使用toast 通知"向用户显示一些警报.

I try now to use "toast notification" to show some alert for user.

所以我使用 Microsoft 示例进行了培训,可在此处获得:http:///code.msdn.microsoft.com/windowsdesktop/sending-toast-notifications-71e230a2/

So I trained with Microsoft sample, available here: http://code.msdn.microsoft.com/windowsdesktop/sending-toast-notifications-71e230a2/

它工作正常,但我必须为我的应用创建一个快捷方式才能使用 toast 通知.

It works fine, but I have to create a shortcut to my app to use toast notification.

我试图删除快捷方式创建,但它不起作用.我理解,因为对于桌面应用程序,快捷方式是 toast 通知的先决条件,您可以在 Microsoft 网站上阅读:http://msdn.microsoft.com/en-us/library/windows/apps/hh802768.aspx

I tried to remove shortcut creation, but it doesn't work. And I understand, because for desktop app, shortcut is a prerequesite for toast notification, as you can read on Microsoft website: http://msdn.microsoft.com/en-us/library/windows/apps/hh802768.aspx

我的问题很简单.如果用户决定删除快捷方式(这是他的个人资料文件夹中的 .lnk),如果没有此快捷方式,我的 toast 通知如何工作?

My question is simple. If user decide to delete shortcut (which is a .lnk in his profile folder), how can make my toast notification work without this shortcut ?

如果没有创建快捷方式,我不想每次在运行时都创建快捷方式,因为用户决定删除它,并且每次都创建它是不正确的.

I don't want to create shortcut every time on runtime if it's not created, because user decided to delete it, and create it every time is not correct.

那么,有没有什么方法可以在没有快捷方式的情况下使用桌面应用程序的 toast 通知?

So, is there any way to use toast notification from desktop app without shortcut ?

推荐答案

文档你引用的似乎很清楚:

您的应用的快捷方式必须是 System.AppUserModel.ID安装到开始屏幕.但请注意,它不需要固定到开始"屏幕.有关详细信息,请参阅如何启用通过 AppUserModelID 的桌面 toast 通知.

A shortcut to your app, with a System.AppUserModel.ID, must be installed to the Start screen. Note, however, that it does not need to be pinned to the Start screen. For more information, see How to enable desktop toast notifications through an AppUserModelID.

请注意,固定"和已安装"之间是有区别的,如果您可以在不固定的情况下安装(不确定是否可以),用户将不太可能找到并删除它.

Note there's a distinction between "pinned" and "installed", if you can install without pinning (unsure if you can) it would be less likely user would find and delete it.

也就是说,永远无法保证快捷方式会在那里.也许您的应用在启动时(或任何时候)可以检测到快捷方式已消失并温和地"通知用户他们的应用体验将不是最佳,然后提供恢复快捷方式(您将以编程方式执行此操作).

That said, there's never any guarantee the shortcut will be there. Perhaps your app on launch (or whenever) could detect that the shortcut is gone and "gently" inform the user that their app experience will be less than optimal, then offer to reinstate the shortcut (which you'd do programmatically).

请记住,用户始终可以按应用或系统范围关闭通知,因此删除快捷方式只是最终用户可能看不到通知的一种方式.

Keep in mind the user can always turn off notifications on an app by app basis or system-wide anyway, so removing the shortcut is only one of the ways the end user might not see your notifications.

这篇关于从桌面应用程序使用 Windows 8 Toast 通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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