简体   繁体   English

NSUserNotification状态

[英]NSUserNotification state

Is there a way to determine if a certain NSUserNotification is still on screen or it has been dismissed? 有没有办法确定某个NSUserNotification是否仍在屏幕上或已被解雇? I haven't found a way to do this. 我还没有办法做到这一点。

I think you could use NSUserNotificationCenterDelegate_Protocol 我想你可以使用NSUserNotificationCenterDelegate_Protocol

It has userNotificationCenter:didActivateNotification: Sent to the delegate when a user clicks on a user notification presented by the user notification center. 它具有userNotificationCenter:didActivateNotification:当用户单击用户通知中心提供的用户通知时发送给代理

But remember it also depends on what type of notification is being used. 但请记住,它还取决于使用的通知类型。 if 'Banners' then it may go away before the user clicks it. 如果是“横幅”,那么它可能会在用户点击之前消失。

So in conjunction to the delegate, you would have to also check the type of notification and if it was Presented. 因此,与代理人一起,您还必须检查通知的类型以及是否已提交。

Update: I have not used NotificationCenter. 更新:我没有使用过NotificationCenter。 So have no code to hand. 所以没有代码可以交给你。 But also look atthe constants: 但也看一下常数:

NSUserNotificationActivationType
These constants describe how the user notification was activated.

enum {
NSUserNotificationActivationTypeNone = 0,
NSUserNotificationActivationTypeContentsClicked = 1,
NSUserNotificationActivationTypeActionButtonClicked = 2
}
typedef NSInteger NSUserNotificationActivationType;
Constants
NSUserNotificationActivationTypeNone
The user did not interact with the notification alert.
Available in OS X v10.8 and later.
Declared in NSUserNotification.h.
NSUserNotificationActivationTypeContentsClicked
The user clicked on the contents of the notification alert.
Available in OS X v10.8 and later.
Declared in NSUserNotification.h.
NSUserNotificationActivationTypeActionButtonClicked
The user clicked on the action button of the notification alert.
Available in OS X v10.8 and later.
Declared in NSUserNotification.h.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM