You can find the latest documentation in headers as usual. First of all, make sure you are using OSX SDK 10.9. There are few new fields with description.
NSUserNotification.h:
// Set to YES if the notification has a reply button. The default value is NO.
// If both this and hasActionButton are YES, the reply button will be shown.
@property BOOL hasReplyButton NS_AVAILABLE(10_9, NA);
// Optional placeholder for inline reply field.
@property (copy) NSString *responsePlaceholder NS_AVAILABLE(10_9, NA);
// When a notification has been responded to, the NSUserNotificationCenter delegate
// didActivateNotification: will be called with the notification with the activationType
// set to NSUserNotificationActivationTypeReplied and the response set on the response property
@property (readonly) NSAttributedString *response NS_AVAILABLE(10_9, NA);
Let's do it:
- (IBAction)showNotification:(id)sender{
NSUserNotification *notification = [[NSUserNotification alloc] init];
...
notification.responsePlaceholder = @"Reply";
notification.hasReplyButton = true;
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
}
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
{
if (notification.activationType == NSUserNotificationActivationTypeReplied){
NSString* userResponse = notification.response.string;
}
}
Notice that the reply button is hidden until mouse is outside a notification window and the reply field will be shown after button click.