1 - Define a class in your project to implement the NSUserNoficationCenterDelegate protocol (registered here )
@interface someObject : NSObject <NSUserNotificationCenterDelegate> { - (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification; }
2 - Install the instance of the object defined by # 1 as the default notification center delegate.
[[NSUserNotificationCenter defaultNotificationCenter] setDelegate: someObject];
Now you will be called on didActivateNotification each time the user clicks / clicks on the notification. You will have the original notice that you created. Therefore, any information that you need should be available to you.
If you need / need special information (except for the title of notifications, messages, etc.), you will probably need to specify additional information for a specific application in your notification before planning to send it. For instance:
NSUserNotification* notification = [[NSUserNotification alloc] init]; NSDictionary* specialInformation = [NSDictionary dictionaryWithObjectsAndKeys: @"specialValue", @"specialKey", nil]; [notification setUserInfo:specialInformation];
source share