Growl is a system for posting notifications to users. Mac OS X offers two built-in ways to do this:
The problem with dialog boxes is threefold:
But what if you just want to quickly alert the user of something non-essential, that users may not necessarily need to react to? For this, there's Growl.
Bezels are mostly only used by Apple applications, and for good reason — there is no supported public API for using them. They also cannot be made sticky so that they act like dialog boxes.
Growl offers a uniform way for you to display notifications, and allows the user to influence the notifications in various ways.
In order to use Growl, your app must first register. The easiest way is to write a registration dictionary file and have it in your application bundle's Resources folder; Growl will detect it when your application launches. Full information on what this file must contain is in the Implementing Growl Support in your Cocoa Application document.
To provide more sophisticated support for Growl, such as the ability to respond to clicks on notifications, you must implement a Growl Delegate. The Growl Delegate can register and re-register manually, though this is usually not necessary.
Each notification has several attributes; some required, others optional.
Identifies the 'class' of notification; for example, "Download started" and "Download finished" are good notification names. Names should be human-readable, as they are listed in the Growl preference pane in your application's ticket.
Displayed to the user when you post the notification. Can be different from the name; nonetheless, a good notification name is also often a good notification title.
Also displayed to the user when you post the notification, the description expands upon the title. A "Download finished" notification, for example, might list the file or files that were downloaded. Other examples:
A notification can have its own icon — for example, if you've just downloaded a file, you might use the icon of the file. It can also have an application icon that overrides the one provided by the delegate or looked up by GAB (growlnotify uses this).
All of the graphical displays included with 0.6 look for the notification icon and then the notification app icon, using whichever is found first. If neither one is found, your application's icon is used. Other displays (such as those created by users, or by the Growl team for future versions of Growl) may place the application icon over the notification icon as a badge.
Every notification has a priority. The priorities are:
Priorities are clamped to this range. For most notifications, Normal is reasonable.
Not all displays use priority. In those that do, priority may affect font, color, or size, or some combination of these. It may also cause a sound (or a different sound) to be played when the notification is displayed. All of this is up to the display designer.
The user can override priority for each notification name.
Non-sticky notifications generally disappear after a short time. Sticky notifications don't — they wait for the user to click on them before they disappear. Your application will still get a click callback if it requested it.
Not all notifications support sticky. It is generally only supported in graphical displays (those which create a window on the screen).
The user can override stickiness for each notification name.
Some developers have objected to the timing-out behaviour of notifications. We ask that you leave notifications non-sticky unless you have a specific reason for them to be sticky, and let the user decide for himself whether he wants the notification to be sticky.
When you supply a non-NULL click context for a notification, and a click callback in the delegate, GAB calls back to your application when the notification is clicked or times out.
Not all displays support click feedback.
Growl applications can be written in many languages using many different libraries. The Growl framework provides a Cocoa API in the form of the GrowlApplicationBridge class. A quick reference to working with GAB:
Takes a pointer (an id) to an object conforming to the GrowlApplicationBridgeDelegate protocol.
Note that the GrowlApplicationBridge class is not a factory class: there is no such thing as a GrowlApplicationBridge instance.
For more detailed documentation, see Implementing Growl Support in your Cocoa Application and the Growl framework headers.
For other languages, there are a number of bindings: