I'm trying to use NSUserNotificationCenter
. I'm able to deliver notifications successfully. I'm using the ShouldPresentNotification
callback on NSUserNotificationCenterDelegate
to present notifications, even when the app is running in the foreground.
This works great, except on one of my machines!
I have stripped the code down to it's most basic example. All my machines are running 10.8.3 and Mono 2.10.12. On my 2008 Macbook Pro and a colleague's 2012 rMBP, everything works as excepted. However, on my identical 2012 rMBP the notification is not presented if the app is in the foreground. In fact, on this machine, and this machine only, none of the NSUserNotificationCenterDelegate
methods are invoked.
Note that the notification is still delivered on this machine - the notification works - it just doesn't get presented when the app is in the foreground (because the delegate methods are never invoked).
I would really appreciate if anyone has some insight on what settings or configuration might causes this behaviour, or if there is some mechanism I can use to debug this behaviour.
Here is my code:
UNCShouldPresentNotification ShouldPresent = (a, b) => { return true; };
// Shared initialization code
void Initialize()
{
NSUserNotificationCenter.DefaultUserNotificationCenter.ShouldPresentNotification = this.ShouldPresent;
}
partial void notify(NSObject sender)
{
DoNotify();
}
[Export("doNotify")]
private void DoNotify()
{
NSUserNotification notification = new NSUserNotification();
notification.Title = notificationText.StringValue;
NSUserNotificationCenter.DefaultUserNotificationCenter.DeliverNotification(notification);
}
This now works, somewhere between updating MonoMac, Mono and OS X on my machine.