C# 如何在UWP/C中获取Windows 10?通知的内容?
我试图获取用户通知中的文本,以及单击通知时发生的操作。我获得用户读取它们的权限(使用C# 如何在UWP/C中获取Windows 10?通知的内容?,c#,uwp,notifications,windows-10,C#,Uwp,Notifications,Windows 10,我试图获取用户通知中的文本,以及单击通知时发生的操作。我获得用户读取它们的权限(使用UserNotificationListener.RequestAccessAsync()),然后迭代它们,并将它们添加到ListView: private async void getNotificationsAsync() { UserNotificationListener listener = UserNotificationListener.Current; IReadOnlyList&
UserNotificationListener.RequestAccessAsync()
),然后迭代它们,并将它们添加到ListView:
private async void getNotificationsAsync()
{
UserNotificationListener listener = UserNotificationListener.Current;
IReadOnlyList<UserNotification> notifs = await listener.GetNotificationsAsync(NotificationKinds.Toast);
NotificationsList.Items.Clear();
foreach (UserNotification notif in notifs)
{
//Console.WriteLine(notif.AppInfo.DisplayInfo.DisplayName);
NotificationsList.Items.Add(notif.AppInfo.DisplayInfo.DisplayName);
}
}
private async void getNotificationsAsync()
{
UserNotificationListener=UserNotificationListener.Current;
IReadOnlyList notifs=wait listener.GetNotificationsAsync(NotificationKinds.Toast);
NotificationsList.Items.Clear();
foreach(通知中的用户通知notif)
{
//Console.WriteLine(notif.AppInfo.DisplayInfo.DisplayName);
NotificationsList.Items.Add(notif.AppInfo.DisplayInfo.DisplayName);
}
}
但是,我只能从中获得启动应用程序的名称(以及通知发生的时间)。在UserNotification
类中,我找不到访问通知内容的任何方法
我所尝试的可能吗?我使用的是正确的类吗 找到了!(总是发生在我问这个问题之后)找到了!(总是发生在我问这个问题之后