objective c - NSUserNotification - How open the app when clicked -
I am using NSUserNotification to display the notifications. It is working fine This problem is that when you Click on Notification:
- Application notifications are not deleted from the Notification Center.
- The app is not open (when at least). "Information." @ Implementation Notice - (zero) Notify: (NSString *) Message {NSLog (@ "Notification - Show It"); NSUserNotification * Notification = [[NSUserNotification alloc] init]; [Notification Situation: [Message Value Forekey: @ "Title"]]; [Notification Set Informative Text: [Message ValueForca: @ "Content"]]; [Notification set delivery date: [NSDT date with timer: 0 to date: [date of NSDT]]]; [Notification SetsNumber: NSUser notification DefaultSoundname]; NSUserNotificationCenter * center = [NSUserNotificationCenter defaultUserNotificationCenter]; [Center schedule notification: notification]; } - (Zero) User Notification Center: (NSUser Notification Center) Center was activated Note: (NSUASAR Notification *) Notification {NSLog (@ "Notification - Clicked"); Notification = nil; [Deleted notice to center: notification]; } #pragma mark WebSpotting Protocol + (BOOL) isCavewordWebWebScript: (SEL) selector {if (selector == @ selector (notify)); Yes come back } + (NSString *) webScriptNameForSelector: (SEL) selector {id result = zero; If (selector == @ selector (notify)) {result = @ "notify"; } Return results; } // Exclude all properties (for example key) now (+ BOOL) isKeyExcludedFromWebScript: (const char *) Name {return yes; } @end
Thanks
Simply apply the NSUserNotificationCenterDelegate and
- (zero) User Information Center: P> I did this in the "Notifier" application.
- (Zero) User Notification Center: (NSUser Notification Center) was activated by the Center: NSUranAlartPanel ([Notification title], [notification notification text], @ "OK", zero, zero ); } - (Zero) User Notification Center: (NSUser Notification Center) Center had delivered the delivery notice: (NSUASAR NOTIFICATION *) NOTIFICATION {NOTIFICATIONS = NIL; [Reload tableview data]; [Deleted notice to center: notification]; }
When the notification is active (clicked by the user) I only inform the user with a panel (I can use a hood window). In case I will immediately remove the information distributed, but it is not what happens normally. The notification can be spent some time and removed after 1/2 hour (depending on the application you are developing).
Comments
Post a Comment