CNUserNotification is a kind of proxy to give OS X Lion 10.7 „the same‟ support for user notifications like OS X Mountain Lion 10.8 does. Benefits are also a bit more flexibility since you are able to define a custom banner image or variable dismiss delay times.
CNUserNotification uses a fake notification center that runs just per application. The class design and all method signatures are similar to their counterparts of
It's not necessary to install Growl or other third party libraries. It's all build in to get the user notified - Mountain Lion style.
CNUserNotification runs on a per application basis all methods related to scheduled or remote deliverey are not implemented. Please take a look at the documentation to get a detailed look.
Here is a screenshot of the included example application:
pod 'CNUserNotification' to your podfile.
Via Git SubModule
cd into your project directory and execute
git submodule add https://github.com/phranck/CNUserNotification.git $DIR_WHERE_YOUR_SUBMODULES_ARE_PLACED
You have to replace the
$DIR_WHERE_YOUR_SUBMODULES_ARE_PLACED with the real path where your submodules are placed.
As described above all method signatures are identical to that ones of
CNUserNotification* classes. Strictly speaking you have to use three classes and one delegate:
CNUserNotification CNUserNotificationCenter CNUserNotificationFeature CNUserNotificationDelegate
CNUserNotificationFeature is the extension that doesn't exist in the original
NSUserNotification, but there is a category to implement just two accessor methods.
The only thing you have to do is to replace the prefix
CN. It's not required to change any code if you use
CNUserNotification. It decides by itself whether to use
NSNotfication or this custom implementation.
CNUserNotification was written using ARC and runs on 10.7 and above. It requires the QuartzCore Framework. The project supports both
x86_64 architectures on 10.7 and 10.8.
The code is provided as-is, and it is far off being complete or free of bugs. If you like this component feel free to support it. Make changes related to your needs, extend it or just use it in your own project. Pull-Requests and Feedbacks are very welcome. Just contact me at [firstname.lastname@example.org](mailto:email@example.com?Subject=[CNUserNotification] Your component on Github) or send me a ping on Twitter @TheCocoaNaut.
The complete documentation you will find on CocoaDocs.
This software is published under the MIT License.