0
votes

I want to integrate Toast notification in my existing CPP/COM based desktop application. To add this, I have followed the step by step guide given at https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/send-local-toast-desktop-cpp-wrl(added GUID and etc in product.wxs and installed it as well). But notification is not getting posted when my code condition calls notifier->Show(). There is some sample project posted by Microsoft on https://github.com/WindowsNotifications/desktop-toasts. But CPP/COM project from this git link is also not able to post the Toast notifications. If I use c# sample from this git, Toast notifications are posted. Is CPP/COM based application needs some changes apart from steps mentioned on MS link(or present in Git sample) to work? Is there any better solution to integrate the toast notifications in the COM based desktop application?

Thanks, Omkar

1
Try another PC, in my desktop it doesn't work either but it works on laptop.Michael Chourdakis

1 Answers

1
votes

But CPP/COM project from this git link is also not able to post the Toast notifications.

By checking the official sample, there is a mistake in it. In the DesktopToastsSample.cpp file, the AUMID it registers in the RegisterAumidAndComServer method is "WindowsNotifications.DesktopToastsCpp", however, in the Product.wxs file of SetupProject, the AUMID it inputs is "WindowsNotifications.DesktopToastsCppWrl". These two AUMIDs do not match, so the notification can't display. In this case, you can modify the AUMID in the Product.wxs file from sample to "WindowsNotifications.DesktopToastsCpp". For example:

Product.wxs:

<ShortcutProperty Key="System.AppUserModel.ID" Value="WindowsNotifications.DesktopToastsCpp"/>

Then build the SetupProject again and install the generated MSI from the bin/Debug folder. After that, launch the Desktop Toasts app from the Start menu, the notification will display.