Function

CFUserNotificationDisplayAlert

Displays a user notification dialog and waits for a user response.

Declaration

SInt32 CFUserNotificationDisplayAlert(CFTimeInterval timeout, CFOptionFlags flags, CFURLRef iconURL, CFURLRef soundURL, CFURLRef localizationURL, CFStringRef alertHeader, CFStringRef alertMessage, CFStringRef defaultButtonTitle, CFStringRef alternateButtonTitle, CFStringRef otherButtonTitle, CFOptionFlags *responseFlags);

Parameters

timeout

The amount of time to wait for the user to dismiss the notification dialog before the dialog dismisses itself. Pass 0 to have the dialog never time out.

flags

A set of flags describing the type of notification dialog to display. The value is normally just the alert level from Alert Levels. If you don’t want a default button displayed, perform a bitwise-OR operation with the alert level and the constant kCFUserNotificationNoDefaultButtonFlag.

iconURL

A file URL pointing to the icon to display in the dialog. If NULL, a default icon is used based on the notification’s alert level specified in flags.

soundURL

Not used.

localizationURL

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

alertHeader

The title of the notification dialog. Cannot be NULL.

alertMessage

The message string to display in the dialog. Can be NULL.

defaultButtonTitle

The title of the default button. If NULL, the string OK is used.

alternateButtonTitle

The title of an optional alternate button. Can be NULL.

otherButtonTitle

The title of an optional third button. Can be NULL.

responseFlags

On return, contains flags identifying how the notification was dismissed. See Response Codes for details.

Return Value

0 if the cancel was successful; a non-0 value otherwise.

Discussion

This function blocks the current thread’s execution until the dialog is dismissed, either by the user or by timing out.

See Also

CFUserNotification Miscellaneous Functions

CFUserNotificationCancel

Cancels a user notification dialog.

CFUserNotificationCheckBoxChecked

Returns a flag used to set or test a checkbox’s state.

CFUserNotificationCreate

Creates a CFUserNotification object and displays its notification dialog on screen.

CFUserNotificationCreateRunLoopSource

Creates a run loop source for a user notification.

CFUserNotificationDisplayNotice

Displays a user notification dialog that does not need a user response.

CFUserNotificationGetResponseDictionary

Returns the dictionary containing all the text field values from a dismissed notification dialog.

CFUserNotificationGetResponseValue

Extracts the values of the text fields from a dismissed notification dialog.

CFUserNotificationGetTypeID

Returns the type identifier for the CFUserNotification opaque type.

CFUserNotificationPopUpSelection

Returns a flag used to set the selected element of a pop-up menu.

CFUserNotificationReceiveResponse

Waits for the user to respond to a notification or for the notification to time out.

CFUserNotificationSecureTextField

Returns a flag used to set the secure state of a text field.

CFUserNotificationUpdate

Updates a displayed user notification dialog with new user interface information.