uwp - 当应用程序在后台时,UWP 会阻止一些通知
问题描述
我想屏蔽一些通知。当应用程序处于前台时,我可以使用以下代码执行此操作:
var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
channel.PushNotificationReceived += Channel_PushNotificationReceived;
然后:
private void Channel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
{
if (args?.NotificationType == PushNotificationType.Toast)
{
if (string.IsNullOrWhiteSpace(args.ToastNotification?.Content?.InnerText))
{
args.Cancel = true;
}
}
}
但是我不知道当应用程序关闭时该怎么做。我尝试了通知侦听器,但只有在通知已经出现时才能访问它们。
我的问题是,当应用程序在后台时,如何阻止一些通知?
解决方案
推荐阅读
- opengl - OpenGL 在 ubuntu 和 windows 中的行为不同
- docker - 是否应该避免使用 docker run 来执行使用 docker-compose 创建的图像?
- javascript - 为什么我在 facebook 业务经理中只能看到第一个产品 SKU?
- scala - 设置 play new 而不是 sbt new 来启动项目
- php - Yii2如何实现乐观锁
- java - 带有 Web API 的 JWT Introspection 中间件 - Java 和 Identity Server
- javascript - 如何在所有浏览器都支持的 javascript 中编写 cookie 测试
- python - 我有一个数组 L 和一个数组 A 的列表。我需要找到 L 中的哪个数组最接近 A
- ios - 添加到gitignore文件后如何永久隐藏文件
- amazon-web-services - TeamCity:将 docker 镜像推送到 AWS ECR