To read notifications from other applications in Windows 10, you can use the UserNotificationListener
class. However, it’s important to note that this class can only read notifications from the current application. It’s not possible to read notifications from other applications due to privacy and security reasons.
How to read notifications coming to Windows with C#
for example; I want to read notifications coming from Facebook, WhatsApp, browser or any application with C#.
2 answers
Sort by: Most helpful
-
Boris 80 Reputation points
2023-11-05T12:42:53.7566667+00:00 -
hellih 0 Reputation points
2023-12-07T05:47:46.5+00:00 Create a new C# console application or open an existing one.
Ensure that you have the necessary references added to your project. Right-click on your project in Visual Studio, choose "Manage NuGet Packages," and search for and install the "Windows Community Toolkit" package. Subscribe to the Notification Activated event:
Add the following using statement at the top of your code file:
using Windows.UI.Notifications;
In your Main method, subscribe to the ToastNotificationManagerCompat.ToastNotificationActivated event:
ToastNotificationManagerCompat.ToastNotificationActivated += ToastNotificationActivated;
Implement the event handler:
Define the ToastNotificationActivated method to handle the notifications: Run the application and wait for notifications:
Run your C# application and keep it running.
Receive notifications from the desired applications, such as Facebook or WhatsApp. on your Windows system.
When a notification is triggered, the ToastNotificationActivated method will be called, and you can access the notification content and handle it as needed.
private static void ToastNotificationActivated(ToastNotificationActivatedEventArgsCompat e) { // Handle the notification here // You can access the notification content using e.Argument or e.UserInput }