[英]NSUserNotification state
有没有办法确定某个NSUserNotification
是否仍在屏幕上或已被解雇? 我还没有办法做到这一点。
我想你可以使用NSUserNotificationCenterDelegate_Protocol
它具有userNotificationCenter:didActivateNotification:当用户单击用户通知中心提供的用户通知时发送给代理 。
但请记住,它还取决于使用的通知类型。 如果是“横幅”,那么它可能会在用户点击之前消失。
因此,与代理人一起,您还必须检查通知的类型以及是否已提交。
更新:我没有使用过NotificationCenter。 所以没有代码可以交给你。 但也看一下常数:
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.