如果操作中心有任何更改,则触发后台任务 [英] BackGround Task to trigger if any changes in the Action Center
问题描述
当应用程序将 toast 通知添加到操作中心时,我需要触发我的后台任务.我已经尝试过 ToastNotificationHistoryChangedTrigger
并且当应用程序添加 toast 通知时它不会触发任务.有什么解决办法吗?
I need to trigger my background task when the application added the toast notification to the action center. I have tried with ToastNotificationHistoryChangedTrigger
and it's not triggering the task when the application added the toast notification.
Is there any solution for it?
推荐答案
ToastNotificationHistoryChangedTrigger 每当您的应用程序的 Toast 通知历史记录集合在设备上发生更改时就会触发.订阅此触发器,将允许您的应用在以下情况下收到通知:
ToastNotificationHistoryChangedTrigger is fired whenever the collection of toast notification history from your app changes on the device. Subscribing this trigger, will allow your app to get notified when:
- 用户从操作中心删除了 Toast 通知;
- Toast 通知已过期并被系统从操作中心移除;
- 通过推送从您的应用发送 Toast 通知;
注意:您的应用唯一不会收到通知的事情是弹出/添加本地 Toast,因为没有必要通知您的应用客户端它刚刚执行的操作.
因此,当应用的通知集合以任何非由应用的本地客户端引起的方式发生更改时,通常可以使用 ToastNotificationHistoryChangedTrigger
通知应用.如果您的应用程序自行添加了 toast 通知,则不会触发触发器.
So generally, an app can be notified with ToastNotificationHistoryChangedTrigger
when the app’s collection of notifications is changed in any way that’s not caused by the app’s local client. If your application added the toast notification by itself, the trigger won't be fired.
这篇关于如果操作中心有任何更改,则触发后台任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!