4

Fairly straightforward, I have an app that should send a notification but it will not do so if the application is frontmost. From the NSUserNotificationCenter class reference:

The user notification center reserves the right to decide if a delivered user notification is presented to the user. For example, it may suppress the notification if the application is already frontmost (the delegate can override this action).

From what I can gather it has to do with the userNotificationCenter:shouldPresentNotification: method that is shown in the NSUserNotificationCenterDelegate protocol reference but I can't figure out how to implement it. I already set my class to be the NSUserNotificationCenterDelegate so that's not it.

Any ideas?

EDIT: In the class I set as the NSUserNotificationCenterDelegate I use this to try to override the original method, which defaults as NO if the app is frontmost:

- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification {
return YES;
}

But nothing happens.

Elbimio
  • 1,041
  • 2
  • 10
  • 25
  • After looking around some more I found the answer here: http://stackoverflow.com/questions/11814903/send-notification-to-mountain-lion-notification-center – Elbimio Aug 24 '12 at 05:16

1 Answers1

5

NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter]; [center scheduleNotification:notification]; center.delegate = self;

  • (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification {return YES;}
Prakash Jat
  • 559
  • 5
  • 8