仅当用户在计算机上时才显示通知 [英] Only show notification if user is at computer
问题描述
什么是检测用户当前是否在其计算机上的最佳方式,即以某种方式使用它。我们有一个应用程序,如果用户在他们的计算机上,应该只发出通知(带有关闭按钮的横幅通知)。
Whats the best way to detect if a user is currently at their computer, ie using it in some way. We have an application that should only issue notifications (banner notifications with a close button) if the user is at their computer.
例如,假设股票交易应用程序,提醒用户可能只有几分钟相关的各种时间敏感信息。
推荐答案
如果用户离开他们的计算机,他们不想找到20个不执行操作的提醒。
技术我不知道如何看待不活动,但我想你可以使用超时通知在一段时间间隔后关闭自己和/或限制显示的通知少,所以最新的将自动关闭最旧的一个
Technicaly I don't know how to watch for inactivity but I think you could use timeout for notifications to close themselves after a time interval and/or to limit displayed notifications to few, so the newest one would automaticaly close the oldest one.
从苹果文档:
注意:用户在计划的
通知被调度为触发超过15分钟后,它被丢弃。如果
通知以小于15分钟的间隔重复,则
在1分钟后到期。已过期的通知只会被舍弃,除非他们重复
,在这种情况下,他们仍然在预定的列表中,只是
稍后再次触发。
Note: It the user wakes more than 15 minutes after a scheduled notification is scheduled to fire, it is discarded. If the notification repeats with an interval less than 15 minutes, then it expires in 1 minute. Expired notifications are just discarded, unless they repeat, in which case, they stay in the scheduled list and just fire again later.
这篇关于仅当用户在计算机上时才显示通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!