user732274
user732274

Reputation: 1069

NSUserNotification state

Is there a way to determine if a certain NSUserNotification is still on screen or it has been dismissed? I haven't found a way to do this.

Upvotes: 3

Views: 1142

Answers (1)

markhunte
markhunte

Reputation: 6932

I think you could use NSUserNotificationCenterDelegate_Protocol

It has userNotificationCenter:didActivateNotification: Sent to the delegate when a user clicks on a user notification presented by the user notification center.

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. 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.

Upvotes: 1

Related Questions