Windows 未调用 Toast 通知回调

Windows Toast Notification callback not being invoked

我成功地发送了 Toast 消息,但是一旦点击,回调就不会被调用。这是使用的toast-tutorial

消息应通过经典 Win32 发送,为此,需要创建一个包含 AUMID 和 CLSID 的快捷方式。这在本教程的第 5 步中进行了解释,其中对于 MSIX 和 WiX,这些 ID 放在它们的配置文件中。没有说明如何在 Win32 中生成快捷方式,但可以在另一个 aumid-tutorial.

中找到

按照提供的步骤操作后,发送吐司可以正常工作,但点击它不会调用处理反馈的回调。 值得注意的一件事是,installShortcut 函数在创建快捷方式时仅使用 AUMID,CLSID 仅在注册 COM 服务器时使用,其中 MSIX 和 WIX 快捷方式的配置同时使用。

似乎缺少 link windows 需要将反馈路由回应用程序。

Toast 使用“ToastGeneric”绑定。

知道为什么会这样吗?

我 运行 desktop-toasts 样本成功。如代码注释注释,

For the app to be activated from Action Center, it needs to provide a COM server to be called when the notification is activated. The CLSID of the object needs to be registered with the OS via its shortcut so that it knows who to call later. The WiX installer adds that to the shortcut. Be sure to install the app via the WiX installer once before debugging!

如果运行直接打包项目,也可以。下图是我安装Wix Toolset生成的DesktopToastsCppWrlApp.msi时发生的情况。

仅凭名称,在我看来您需要在 .lnk 上设置 PKEY_AppUserModel_ToastActivatorCLSID 属性 而不仅仅是 AUMID。

MSDN 说:

Used to CoCreate an INotificationActivationCallback interface to notify about toast activations.

This page 被标记为预发布但确实有一个不同的 InstallShortcut 函数设置这个 属性.