Search code examples
c#mononotificationsmonomac

Using Mac notifications with Monomac


I am currently porting a simple tray application from Windows (C#, .Net, Winforms) to OS X (C#, MonoMac, Cocoa). Most of the work is done, but I'm having some trouble with the OS X equivalent of the balloon tooltip that Windows tray applications often use to share information: Balloon tooltip example

I haven't used OS X very much, but I am under the impression that the equivalent is a Notification: Notification example

But I cannot figure out how to use this from MonoMac. When looking around on the internet, I find something called "Growl notifications", but this seems to be a third party library, which I'm not interested in (if it can be avoided). There is also a class called NSNotification in the MonoMac framework, but again, I am unable to make it work.

Does anybody have a couple of hints for a poor Windows programmer?


Solution

  • The equivalent on Mac is the notification center. This was introduced in OS 10.8 (Mountain Lion).

    Before notification center was introduced, this functionality could be added with the third party library Growl. Growl is still applicable in many cases as it is more functional than the native notification center. Growl is a paid add-on that users have to buy and install.

    NSNotification is part of a Mac API that is used for passing messages between objects and processes. It is not a 'user' notification. It is confusing because NSNotification and NSNotificationCenter are the names of these older APIs; while the newer 'user' notification APIs that you are interested in are called NSUserNotification and NSUserNotificationCenter.

    Assuming your users are on 10.8 / Mountain Lion, it would be best to use the OS X notification center. It appears there is an example demonstrating this. If you must support earlier versions, Growl is a good option but users will have to purchase/install it. Otherwise, you could develop something yourself.

    One additional point is that Growl does integrate with the native notification center, so it's not necessarily an 'either/or' decision. It just depends on what you want to support.