Waits for the user to respond to a notification or for the notification to time out.
- macOS 10.0+
- Core Foundation
The user notification to use.
The amount of time to wait for the user to respond to
useror for the notification to time out. If neither happens before
timeoutpasses, this function returns a non-
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
responsehold 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
CFUser. 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:
Notification Check Box Checked
Flags >> 24
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
CFUser. You will then receive a callback when the dialog is dismissed.