Browser Notifications with Yip
Ever wanted your web application to be able to show notifications even if the user may be in another browser tab or application? Now you can!
The relatively new Yip extension for Firefox adds notification functionality. This is not a small JavaScript notification that pops up in the browser tab, but one that integrates directly with the users Operating System.
Yip uses libnotify/notify-osd on Ubuntu Linux, Growl on Mac, and Snarl or Growl for Windows on Windows. If none of these notification applications are installed, it will use Firefox’s simple and not as pretty notification system. Ubuntu Linux users have notify-osd installed by default, Growl is popular with Mac users, yet Windows users probably don’t have Snarl or Growler for Windows installed.
When building with notifications remember that they are meant to enhance the user experience, not require it.
The Yip extension supports both the Fluid and Prism APIs, but recommends Fluid because of support for an onclick callback function.
The API is simple and straight to the point:
window.fluid.showGrowlNotification({
title: "your notification title",
description: "some description",
onclick: optionalCallbackFunction,
icon: "URL to an icon"
});
Since Yip may not be installed on the users computer, just wrap it with a check for fluid. A complete example looks like this:
if (typeof(fluid) !== 'undefined') {
window.fluid.showGrowlNotification({
title: "Hello World",
description: "The Google icon says Hi",
icon: "http://www.google.com/favicon.ico"
});
}
Related Projects
- Roar: Embed notifications into a web page (powered by MooTools).
- growl.js: Windows only notifications using Growl for Windows.
- NotificationAPI: Notifications in Google Gears
Of all these options, Yip is the best solution by far; its fully cross platform, has a simple to use API, and is ready to use. Install Yip now.