简体   繁体   English

Windows Toast 通知回调未被调用

[英]Windows Toast Notification callback not being invoked

I managed to send Toast messages but once clicked, the callback is not invoked.我设法发送了 Toast 消息,但是一旦单击,就不会调用回调。 This is the toast-tutorial that was used.这是使用的吐司教程

The messages should be sent through classic Win32 and in order to do this, a shortcut needs to be created which contains the AUMID and the CLSID.消息应通过经典 Win32 发送,为此,需要创建一个包含 AUMID 和 CLSID 的快捷方式。 This is explained in Step 5 of the tutorial, where for MSIX and WiX these id's are put in their config files.这在本教程的第 5 步中进行了解释,对于 MSIX 和 WiX,这些 id 被放入它们的配置文件中。 There isn't an explanation how to generate the shortcut in Win32, but can be found in another aumid-tutorial .没有说明如何在 Win32 中生成快捷方式,但可以在另一个aumid-tutorial中找到。

After following the steps provided, sending the toast works fine, but clicking it does not invoke the callback for handling the feedback.按照提供的步骤操作后,发送 toast 可以正常工作,但单击它不会调用回调来处理反馈。 One thing that stands out, is that the installShortcut function uses only the AUMID in the creation of the shortcut, the CLSID is only used when registering the COM Server, where the configuration for MSIX and WIX shortcuts use both.突出的一点是 installShortcut function 在创建快捷方式时仅使用 AUMID,CLSID 仅在注册 COM 服务器时使用,其中 MSIX 和 ZC486437F72BEA4864F74F72BEA486B7E6 快捷方式的配置均使用。

It seems as there is the link missing that windows needs to route the feedback back into the app.似乎缺少 windows 需要将反馈路由回应用程序的链接。

Toasts use the "ToastGeneric" binding. Toast 使用“ToastGeneric”绑定。

Any idea why this is happening?知道为什么会这样吗?

I have run the desktop-toasts sample successfully.我已经成功运行了desktop-toasts示例。 As the code comment comments,作为代码注释注释,

For the app to be activated from Action Center, it needs to provide a COM server to be called when the notification is activated.对于要从操作中心激活的应用程序,它需要提供一个 COM 服务器以在激活通知时调用。 The CLSID of the object needs to be registered with the OS via its shortcut so that it knows who to call later. object 的 CLSID 需要通过其快捷方式向操作系统注册,以便它知道以后要调用谁。 The WiX installer adds that to the shortcut. WiX 安装程序将其添加到快捷方式中。 Be sure to install the app via the WiX installer once before debugging!请务必在调试前通过 WiX 安装程序安装应用程序一次!

If running the package project directly, It also works.如果直接运行 package 项目,它也可以工作。 The following picture shows What happens when I installed DesktopToastsCppWrlApp.msi generated by Wix Toolset.下图是我安装了Wix Toolset生成的DesktopToastsCppWrlApp.msi后会发生什么。 在此处输入图像描述

Just on the name alone it seems to me like you need to set the PKEY_AppUserModel_ToastActivatorCLSID property on the.lnk and not just the AUMID.仅就名称而言,在我看来,您需要在.lnk 上设置PKEY_AppUserModel_ToastActivatorCLSID属性,而不仅仅是 AUMID。

MSDN says: MSDN 说:

Used to CoCreate an INotificationActivationCallback interface to notify about toast activations.用于共同创建 INotificationActivationCallback 接口以通知 toast 激活。

This page is marked as pre-release but does have a different InstallShortcut function that sets this property. 此页面被标记为预发布,但确实有不同的 InstallShortcut function 设置此属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM