是否有一种方法可以确定某个NSUserNotification是否仍在屏幕上,还是已被驳回?我还没找到办法。
发布于 2012-08-18 12:05:22
我想你可以用协议
当用户单击用户通知中心提供的用户通知时,它会将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.https://stackoverflow.com/questions/12017986
复制相似问题