NSUserNotificationCenterDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in OS X v10.8 and later.
Declared in
NSUserNotification.h

Overview

The NSUserNotificationCenterDelegate protocol allows customization of the behavior of the default NSUserNotificationCenter instance.

Tasks

User Notification Delivery Information

User Notification Display Override

Instance Methods

userNotificationCenter:didActivateNotification:

Sent to the delegate when a user clicks on a user notification presented by the user notification center.

- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
Parameters
center

The user notification center.

notification

The user notification object.

Discussion

This would be a good time to take action in response to user interacting with a specific notification.

To take an action when your application is launched as a result of a user clicking on a notification, be sure to implement the applicationDidFinishLaunching: method in the application class that implements the NSApplicationDelegate Protocol protocol. The notification parameter to that method has a userInfo dictionary, and if that dictionary has the NSApplicationLaunchUserNotificationKey key. The value of that key is the NSUserNotification object that caused the application to launch. The NSUserNotification object is delivered to the NSApplication delegate because that message will be sent before your application has a chance to set a delegate for the NSUserNotificationCenter.

Availability
  • Available in OS X v10.8 and later.
Declared In
NSUserNotification.h

userNotificationCenter:didDeliverNotification:

Sent to the delegate when a notification delivery date has arrived.

- (void)userNotificationCenter:(NSUserNotificationCenter *)center didDeliverNotification:(NSUserNotification *)notification
Parameters
center

The user notification center.

notification

The user notification object.

Discussion

This method is always called, regardless of your application state and even if you deliver the user notification yourself using deliverNotification:.

This delegate method is invoked before the userNotificationCenter:shouldPresentNotification: delegate method.

Availability
  • Available in OS X v10.8 and later.
Declared In
NSUserNotification.h

userNotificationCenter:shouldPresentNotification:

Sent to the delegate when the user notification center has decided not to present your notification.

- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification
Parameters
center

The user notification center.

notification

The user notification object.

Return Value

YES if the user notification should be displayed regardless; NO otherwise.

Availability
  • Available in OS X v10.8 and later.
Declared In
NSUserNotification.h