Win 10 应用程序:删除吐司通知 [英] Win 10 app: remove toast notification

查看:27
本文介绍了Win 10 应用程序:删除吐司通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我显示 Toast 通知,然后它会出现在通知中心.

I show toast notification that it then appears on notification center.

然后我希望以编程方式从通知中心删除该通知.我怎样才能做到这一点?该应用程序可能会在显示通知和我需要删除它之间关闭并重新启动.

I want then to programatically remove that notification from notification center. How can I do this? The app may be closed and restarted between time the notification is shown and when I need to remove it.

推荐答案

您可以使用 ToastNotificationHistory 类.例如:

You can programmatically remove notifications from the action center by using one of the various methods of the ToastNotificationHistory class. For example:

ToastNotificationManager.History.Remove("toast-tag");

其中 "toast-tag"Tag 要删除的 ToastNotification.还有其他重载.

where "toast-tag" is the Tag of the ToastNotification that you want to remove. There are other overloads too.

如果您需要在应用未运行的某个时间点删除通知,则需要从后台任务中执行此操作.

If you need to remove notifications at some point in time when your app isn't running, then you'll need to do so from a background task.

这篇关于Win 10 应用程序:删除吐司通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆