ToastNotificationManagerCompat.OnActivated event not invoked when toast action triggered with a closed app
See original GitHub issueDescribe the bug
I am following the description, defined in Send a local toast notification from C# apps, for handling toast actions in a winui 3 app (packaged) and are using WindowsAppSDK-1.00-preview2. Everything works as described except when the app has been closed before the toast comes up and the user then clicks the toast (toast itself or a button in there):
- The app is launched successfully,
- The call to
ToastNotificationManagerCompat.WasCurrentProcessToastActivated()
returns true, but - The
ToastNotificationManagerCompat.OnActivated
event is not triggered.
Because the event is not triggered there is no possibility to find out which button the user has clicked on the toast.
Steps to reproduce the bug
Create a winui desktop app. Implement the code and manifest changes defined in Send a local toast notification from C# apps. Trigger a toast notification with a button inside the toast. Close the app. Click the button in the toast notification.
Expected behavior
The ToastNotificationManagerCompat.OnActivated
event must be invoked.
Screenshots
No response
NuGet package version
No response
Windows app type
- UWP
- Win32
Device form factor
No response
Windows version
No response
Additional context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Thanks for trying this. I checked your solution and it turned out that I was using “CommunityToolkit.WinUI.Notifications” Version=“7.0.3” instead of “Microsoft.Toolkit.Uwp.Notifications 7.1.1”. It now works OK. It’s not always easy to find out which packages we can use, especially for Notifications. Choosing the CommunityToolkit seemed to be logical since it has this WinUI name in the namespace and I am using it on a WinUI Desktop project.
FYI, we’ve just shipped our 7.1.1-preview3 release for 1.0-preview3 so these packages have all been updated as part of that: https://github.com/CommunityToolkit/WindowsCommunityToolkit/releases/tag/winui-7.1.1-preview3