📎 Webclip
A handy wrapper for the Web Notifications API
Notify.js is a JavaScript plugin that wraps the Web Notifications API so it is easier to reuse across projects. The page says it simplifies permission requests and notification events, and adds a few callbacks and convenience methods.
Reading notes#
- The author says the Web Notifications API is supported in Chrome, Safari 6, and recently in Firefox.
- It creates growl-style notifications for web applications and integrates with Notification Centre on OSX.
- Notify.js is described as a simplified wrapper for the API.
- It aims to simplify permission requests and related Web Notification API events.
- It also provides extra callbacks and convenience methods.
- A notification is created with a new
Notifyinstance, using a requiredtitleand optional settings. - The example passes
bodyandnotifyShow, then callsshow()to display the notification. - Required parameters include
titleas the notification title. - Optional parameters include
body,icon,tag,timeout, and callbacks for show, close, click, error, permission granted, and permission denied. - Static methods include
Notify.needsPermission(),Notify.requestPermission(), andNotify.isSupported(). - Chrome does not allow permission requests on page load; it needs a user interaction such as a click.
- Testing uses Node and the Karma test runner, with
npm install -g karmaandnpm testfor a single pass in Firefox. - The page points to the GitHub readme for current browser support details.
