Reputation: 21
The scenario I encountered is: My app would listen to any popped-up toast notification and do user-defined staff. I Spent time on the msdn, and it looks like only windows 10 supports the toast notification listener staff, and only found an example has been provided by C#: https://blogs.msdn.microsoft.com/tiles_and_toasts/2016/05/26/notification-listener-documentation-windows-10/
Do they have an alternative C++ code for this?
Upvotes: 2
Views: 1974
Reputation: 21926
UserNotificationListener requires the very latest version of Windows 10, 10.0.14393.0, Windows 10 Anniversary Update, only released a couple months ago.
If you’re OK with that limitation, than yes, you can use it from C++.
The simplest way is set “Consume the Windows Runtime language Extensions (/ZW)” in your project properties. You can also set this compiler option for the individual .cpp source file where you going to use that UserNotificationListener class.
Note the documentation for UserNotificationListener class and its methods have “C++” tab.
Unfortunately, C++ currently has no “await”. To get results of asynchronous methods like RequestAccessAsync and others, you’ll have to write some .then() with lambdas. See this answer for more.
Upvotes: 1