【发布时间】:2012-08-19 14:47:53
【问题描述】:
相当简单,我有一个应该发送通知的应用程序,但如果应用程序位于最前面,它就不会这样做。来自 NSUserNotificationCenter 类参考:
用户通知中心保留决定是否 交付用户 通知被呈现给用户。例如,它可能会抑制 如果应用程序已经是最前面的通知(委托可以覆盖 这个动作)。
据我所知,它与 NSUserNotificationCenterDelegate 协议参考中显示的 userNotificationCenter:shouldPresentNotification: 方法有关,但我不知道如何实现它。我已经将我的类设置为 NSUserNotificationCenterDelegate 所以不是这样。
有什么想法吗?
编辑: 在我设置为 NSUserNotificationCenterDelegate 的类中,我使用它来尝试覆盖原始方法,如果应用程序位于最前面,则默认为 NO:
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification {
return YES;
}
但是什么也没发生。
【问题讨论】:
-
环顾四周后,我在这里找到了答案:stackoverflow.com/questions/11814903/…
标签: cocoa delegates nsusernotification