Dialog Description Keys

Keys used in a user notification’s description dictionary, which describes the contents of the notification dialog to display.

Overview

When creating the user notification with CFUserNotificationCreate, the description dictionary must have a value for kCFUserNotificationAlertHeaderKey. All other keys are optional.

The button title keys must be given in right-to-left order—you therefore must use the kCFUserNotificationDefaultButtonTitleKey constant for the rightmost button even if it is conceptually not a "default" button (for example, if you want a single "Cancel" button that should not have color, should not pulse, and should not have return for a key equivalent). If, however, you set the kCFUserNotificationNoDefaultButtonFlag, the rightmost button does not behave as a default button (although it will still be the "default" button in the sense of using kCFUserNotificationDefaultButtonTitleKey and kCFUserNotificationDefaultResponse). The following code fragment shows how you can create a notification that contains a single "Cancel" button that does not behave as a default button.

const void* keys[] = {kCFUserNotificationAlertHeaderKey,
                      kCFUserNotificationProgressIndicatorValueKey,
                      kCFUserNotificationDefaultButtonTitleKey};
const void* values[] = {CFSTR("Progress"),
                        kCFBooleanTrue,
                        CFSTR("Cancel")};
CFDictionaryRef parameters = CFDictionaryCreate(0, keys, values,
        sizeof(keys)/sizeof(*keys), &kCFTypeDictionaryKeyCallBacks,
        &kCFTypeDictionaryValueCallBacks);
SInt32 err = 0;
CFUserNotificationCreate(kCFAllocatorDefault, 0,
        kCFUserNotificationPlainAlertLevel | kCFUserNotificationNoDefaultButtonFlag,
        &err, parameters);

If you set the kCFUserNotificationNoDefaultButtonFlag flag and do not specify a value for kCFUserNotificationDefaultButtonTitleKey, the notification will have no buttons.

Topics

Constants

kCFUserNotificationIconURLKey

A file URL pointing to the icon to display in the dialog.

kCFUserNotificationSoundURLKey

A file URL pointing to a sound that will be played when the alert appears.

kCFUserNotificationLocalizationURLKey

A file URL pointing to a bundle that contains localized versions of the strings displayed in the dialog.

kCFUserNotificationAlertHeaderKey

The title of the notification dialog.

kCFUserNotificationAlertMessageKey

The message string to display in the dialog.

kCFUserNotificationDefaultButtonTitleKey

The title of the default button.

kCFUserNotificationAlternateButtonTitleKey

The title of an optional alternate button.

kCFUserNotificationOtherButtonTitleKey

The title of an optional third button.

kCFUserNotificationProgressIndicatorValueKey

A value to indicate the progress of an operation.

kCFUserNotificationPopUpTitlesKey

The list of strings to display in a pop-up menu.

kCFUserNotificationTextFieldTitlesKey

The list of titles for all the text fields to display.

kCFUserNotificationCheckBoxTitlesKey

The list of titles for all the checkboxes or radio buttons to display.

kCFUserNotificationTextFieldValuesKey

The list of values to put into the text fields. If only one text field is to be displayed, you can pass its value string directly without putting it into an array first.

kCFUserNotificationPopUpSelectionKey

The item that was selected from a pop-up menu.