【问题标题】:UWP UserNotification AppInfo NotImplementedExceptionUWP UserNotification AppInfo NotImplementedException
【发布时间】:2018-06-24 08:00:55
【问题描述】:

我尝试从我的设备获取所有通知,但我无法获取应用程序名称。

            UserNotificationListener notificationListener = UserNotificationListener.Current;
            UserNotificationListenerAccessStatus accessStatus = await notificationListener.RequestAccessAsync();

            if (accessStatus == UserNotificationListenerAccessStatus.Allowed)
            {
                var notifications = await notificationListener.GetNotificationsAsync(NotificationKinds.Toast);

                foreach (var notification in notifications)
                {
                    // Here is exception                
                    System.Diagnostics.Debug.WriteLine(notification.AppInfo.DisplayInfo);
                }
            }

当我诉诸 AppInfo 属性时,我得到了 NotImplementedException。 我哪里错了?

【问题讨论】:

    标签: c# push-notification uwp notifications


    【解决方案1】:

    某些通知将无法检索应用信息。在文档中,出于这个原因,建议将所有与处理单个通知相关的代码都包含在 try/catch 中...

    我们建议您围绕所有代码处理单个 try/catch 中的通知,以防发生意外异常 当您捕获单个通知时。你不应该完全 仅仅因为一个问题而无法显示其他通知 具体通知。

    如果您确定通知来自哪个应用并告知我们,我们可以尝试解决该问题。这些通常是 Win32 应用程序。谢谢!

    【讨论】:

    • 是的,我尝试了 try/catch,但它只是抛出了一个异常 :) 我测试了 Telegram 和 VK Notifications 并且问题相同。
    猜你喜欢
    • 2021-06-30
    • 2021-11-24
    • 2011-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多