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


SInt32 CFUserNotificationReceiveResponse(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags *responseFlags);



The user notification to use.


The amount of time to wait for the user to respond to userNotification or for the notification to time out. If neither happens before timeout passes, this function returns a non-0 value. If timeout is 0, the function blocks until the user notification is dismissed.


On return, contains flags identifying how the notification was dismissed, the state of any checkboxes, and the selected element of the pop-up menu. Bits 0-1 of the value hold an identifier for the button pressed by the user (see Response Codes). Extract the identifier by performing a bitwise-AND operation with 0x3. Bits 8-15 of responseFlags hold the state of up to 8 checkboxes or radio buttons, if present. Extract the flags by performing bitwise-AND operations with the return value of CFUserNotificationCheckBoxChecked. Bits 24-31 hold the index number of the element selected in a pop-up menu, if present. Extract the index by performing a 24-bit right shift: responseFlags >> 24.

Return Value

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


Use this function to poll a user notification for a user response. You can call it any number of times on the same user notification.

To avoid polling and blocking your thread’s execution, you can create a run loop source for the user notification with CFUserNotificationCreateRunLoopSource. You will then receive a callback when the dialog is dismissed.

See Also

CFUserNotification Miscellaneous Functions


Cancels a user notification dialog.


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


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


Creates a run loop source for a user notification.


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


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


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


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


Returns the type identifier for the CFUserNotification opaque type.


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


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


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