HTML5: Notification API

It’s a common problem. While the user is looking away from the document or is interacting with some other section, something updates in the background of the page. Be it an incoming e-mail, message, or some otherwise important content, the page now needs to notify the user of this information, but is limited to either playing a sound or calling something like an alert. To get the user’s attention, in other words, the page needs to interrupt whatever the user was doing.

This is where the Notification API comes in, exposing functions for letting the user give permission for a page to create notifications that will appear outside of the browser itself to signal something. By being tied to a user gesture event, the Notification API can allow a long-running web app to produce short messages with event listeners tied to its controls. The user can either dismiss the message or, if a function is attached to the confirmation button, show additional details about the message without the user having to load the whole document itself.

Unfortunately, support for the Notification API is currently limited to primarily Chrome and Firefox, but with support also in Safari on OS X 10.8+. The Mozilla Developers Network page has good coverage of how an implementation might work in a project. It also details the necessary options for those who might wants to include Notification support in their application manifest files.