NSUserNotification Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in OS X v10.8 and later. |
| Declared in | NSUserNotification.h |
Overview
The NSUserNotification class is used to configure a notification that is scheduled for display by the NSUserNotificationCenter class.
The NSUserNotification object not only configures the notification, when the notification is delivered information about when the notification was actually presented to the user (if at all) and other details are provided in the notification object. User applications can create NSUserNotification objects and register them with the NSUserNotificationCenter object to notify the user when an application requires attention.
See NSUserNotificationCenter Class Reference for more information.
Threading Information
The NSUserNotificationCenter class and the NSUserNotification class are both thread safe.
Tasks
Display Information
-
titleproperty -
subtitleproperty -
informativeTextproperty
Displayed Notification Buttons
-
hasActionButtonproperty -
actionButtonTitleproperty -
otherButtonTitleproperty
Delivery Timing
-
deliveryDateproperty -
actualDeliveryDateproperty -
deliveryRepeatIntervalproperty -
deliveryTimeZoneproperty
Delivery Information
User Notification Activation Method
-
activationTypeproperty
User Notification User Information
-
userInfoproperty
Properties
actionButtonTitle
Specifies the title of the action button displayed in the notification.
Discussion
This value should localized as it will be presented to the user. The string will be truncated to a length appropriate for display and the property will be modified to reflect the truncation.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserNotification.hactivationType
Specifies what caused a user notification to occur. (read-only)
Discussion
This property specifies why the user notification was sent to to the NSUserNotificationCenterDelegate method userNotificationCenter:didActivateNotification:. The supported values are described in “NSUserNotificationActivationType.”
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserNotification.hactualDeliveryDate
The date this notification was actually delivered. (read-only)
Discussion
The notification center will set this value if a notification is put in the scheduled list and the delivery time arrives.
If the notification is delivered directly using the deliverNotification: method of the NSUserNotificationCenter class, this value will be set to the deliveryDate value. If the deliveryDate value nil this value is set to the current date.
This value is used to sort the list of notifications in the user interface.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserNotification.hdeliveryDate
Specifies when the notification should be delivered.
Discussion
The delivery date is specified in an absolute time.
After a notification is delivered, it may be presented to the user.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserNotification.hdeliveryRepeatInterval
Specifies the date components that control how often a user notification is repeated.
Discussion
This value may be nil if the notification should not repeat.
The date component values are relative to the date the notification was delivered.
If the calendar value of the deliveryRepeatInterval is nil, the current calendar will be used to calculate the repeat interval. For example, if a notification should repeat every hour, set the hour property of the deliveryRepeatInterval to 1.
This value is ignored unless the user notification is scheduled with the NSUserNotificationCenter object.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserNotification.hdeliveryTimeZone
Specify the time zone to interpret the delivery date in.
Discussion
If this value is nil and the user switches time zones, the notification center will adjust the time of presentation to account for the time zone change.
If a notification should be delivered at a time in a specific time zone (regardless of whether the user switches time zones), set this value to the specific time zone, for example the current time zone.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserNotification.hhasActionButton
Specifies whether the notification displays an action button.
Discussion
Set to NO if the notification has no action button. This will be the case for notifications that are purely for informational purposes and have no user action.
The default value is YES.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserNotification.hinformativeText
The body text of the notification.
Discussion
This value should localized as it will be presented to the user. The string will be truncated to a length appropriate for display and the property will be modified to reflect the truncation.
Availability
- Available in OS X v10.8 and later.
See Also
Declared In
NSUserNotification.hotherButtonTitle
Specifies a custom title for the close button in an alert-style notification.
Discussion
This value should localized as it will be presented to the user. The string will be truncated to a length appropriate for display and the property will be modified to reflect the truncation.
An empty string will cause the default localized text to be used. A nil value is invalid.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserNotification.hpresented
Specifies whether the user notification has been presented. (read-only)
Discussion
In some cases, for example when your application is frontmost, the notification center may decide not to actually present a delivered notification. In that case, the value of this property will be NO. It will be set to YES if the notification was presented according to user preferences.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserNotification.hremote
Specifies whether the remote was generated by a push notification. (read-only)
Discussion
If this property is YES then the user notification was generated by a push notification (that is, remotely); if NO it was generated locally.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserNotification.hsoundName
Specifies the name of the sound to play when the notification is delivered.
Discussion
Passing the NSUserNotificationDefaultSoundName constant causes the default notification center sound to be played.
A value of nil means no sound is played.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserNotification.hsubtitle
Specifies the subtitle of the notification.
Discussion
This value should localized as it will be presented to the user. The string will be truncated to a length appropriate for display and the property will be modified to reflect the truncation.
Availability
- Available in OS X v10.8 and later.
See Also
Declared In
NSUserNotification.htitle
Specifies the title of the notification.
Discussion
This value should localized as it will be presented to the user. The string will be truncated to a length appropriate for display and the property will be modified to reflect the truncation.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserNotification.huserInfo
Application-specific user info that can be attached to the notification..
Discussion
All items must be property list types or an exception will be thrown.
The userInfo content must be of reasonable serialized size (less than 1k) or an exception will be thrown.
Availability
- Available in OS X v10.8 and later.
Declared In
NSUserNotification.hConstants
NSUserNotificationActivationType
These constants describe how the user notification was activated.
enum {
NSUserNotificationActivationTypeNone = 0,
NSUserNotificationActivationTypeContentsClicked = 1,
NSUserNotificationActivationTypeActionButtonClicked = 2
}
typedef NSInteger NSUserNotificationActivationType;
Constants
NSUserNotificationActivationTypeNoneThe user did not interact with the notification alert.
Available in OS X v10.8 and later.
Declared in
NSUserNotification.h.NSUserNotificationActivationTypeContentsClickedThe user clicked on the contents of the notification alert.
Available in OS X v10.8 and later.
Declared in
NSUserNotification.h.NSUserNotificationActivationTypeActionButtonClickedThe user clicked on the action button of the notification alert.
Available in OS X v10.8 and later.
Declared in
NSUserNotification.h.
NSUserNotificationDefaultSoundName
The default sound played by the user notification center for this notification.
NSString * const NSUserNotificationDefaultSoundName;
Constants
© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-07-23)