Socket
Socket
Sign inDemoInstall

node-notifier

Package Overview
Dependencies
4
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-notifier

A Node.js module for sending notifications on mac, windows and linux


Version published
Maintainers
1
Install size
675 kB
Created

Package description

What is node-notifier?

The node-notifier package is a Node.js module for sending native notifications on different platforms like Windows, Mac, and Linux. It provides an easy-to-use API to show system notifications using the native notification system of the operating system.

What are node-notifier's main functionalities?

Cross-platform notifications

This feature allows you to send desktop notifications across different operating systems. The code sample shows how to send a simple notification with a title and a message.

const notifier = require('node-notifier');
notifier.notify({
  title: 'My notification',
  message: 'Hello, this is a notification!'
});

Notification actions

This feature allows you to listen for user interactions with the notification, such as clicking on it. The code sample demonstrates how to handle a click event on the notification.

const notifier = require('node-notifier');
notifier.notify({
  title: 'My notification',
  message: 'Click to perform an action',
  wait: true
}, (err, response, metadata) => {
  if (metadata.activationType === 'clicked') {
    console.log('Notification clicked!');
  }
});

Custom notification sound

This feature allows you to customize the notification sound and appearance. The code sample shows how to send a notification with a custom sound and icon.

const notifier = require('node-notifier');
notifier.notify({
  title: 'My notification',
  message: 'With a custom sound!',
  sound: true, // Only Notification Center or Windows Toasters
  appIcon: '/path/to/icon.png', // Absolute path (doesn't work on balloons)
  contentImage: '/path/to/image.png' // Absolute Path to Attached Image (Content Image)
});

Other packages similar to node-notifier

Readme

Source

node-notifier NPM version Build Status Dependency Status

A node module for sending notification using node. Uses terminal-notifier on mac, notify-send for Linux and growl for others.

For mac this is a wrapper for the terminal-notifier application by Eloy Durán.

Requirements

  • Mac OS X (>= 10.8. If earlier versions, Growl is used as fallback)
  • Linux with the notify-send module
  • Or Growl on Windows

If using Linux, notify-send must be installed on your system. However, terminal-notifier, comes bundled in the module. So on Mac, not additional installations is necessary.

If using Windows/Growl, growl must be installed. For windows see Growl for Windows. You can also use growl on mac, but you need to specify this manually (see API).

By default Notification Center will be used on Mac, notify-send will be used on Linux, and Growl will be used if neither Mac 10.8 or Linux.

Install

$ npm install node-notifier

Standard Usage

var Notification = require('node-notifier');

var notifier = new Notification();
notifier.notify({
	message: 'Hello World'
});

Notification also has specifications for all types of notifications, to be used manually.

Example:

var nn = require('node-notifier');

new nn.NotificationCenter().notify();
new nn.NotifySend().notify();
new nn.Growl().notify(options);

Mapping between notifiers

Common options between the modules (i.e. icon) is mapped. This means, if you are using a Mac and someone on your project is using Linux, you can both see icons.

Usage NotificationCenter

Same usage and parameter setup as terminal-notifier.

Native Notification Center requires Mac OS X version 10.8 or higher. If you have earlier versions, Growl will be the fallback. If Growl isn't installed, an error will be thrown.


Note: Output parsing from Notification Center is deprecated as of 3.0.0.

Parsing of output given by terminal-notifier is removed as of node-notifier 3.0.0. You can still use both remove and list but the output given will not be parsed into a object.

See removed documentation for pre version 3.0.0 in Deprecated documentation


Example

Where terminal-notifier say to use the -message option, you can do this in node-notifier

var Notification = require('node-notifier');

var notifier = new Notification();
notifier.notify({
	message: 'Hello World'
});

You can specify the second argument as a callback for getting error and response.

var Notification = require('node-notifier');

var notifier = new Notification();
notifier.notify({
	title: 'My application',
	message: 'New notification'
}, function(error, response) {
	console.log(response);
});

As of version 3.0.0, you can also specify image used as icon or content image. For Mac OS notifications, requires 10.9.


notifier.notify({
  "title": "Phil Coulson",
  "subtitle": "Agent of S.H.I.E.L.D.",
  "message": "If I come out, will you shoot me? 'Cause then I won't come out.",
  "sound": "Funk", // case sensitive
  "contentImage": __dirname + "/coulson.jpg",
  "appIcon": __dirname + "/coulson.jpg",
  "open": "file://" + __dirname + "/coulson.jpg"
});

See terminal-notifier for more options.

Usage NotifySend

var Notification = require('node-notifier');

var notifier = new Notification();
notifier.notify({
	title: 'Foo',
	message: 'Hello World',
  icon: __dirname + "/coulson.jpg",
	// .. and other notify-send flags
});

See flags and options on the man pages

Usage Growl

var Notification = require('node-notifier');

var notifier = new Notification({
	// Options as passed to Growler
});
notifier.notify({
	title: 'Foo',
	message: 'Hello World',
  icon: fs.readFileSync(__dirname + "/coulson.jpg")
	// and other growl options like sticky etc.
});

See more information for constructor options in growler.

Changelog

v3.1.0

  1. Adds Growl as fallback for Mac OS X pre 10.8.

v3.0.6

  1. Fixes typo: Changes Growl app name from Gulp to Node.

v3.0.5

  1. Maps common options between the different notifiers. Allowing for common usage with different notifiers.

v3.0.4

  1. Fixes expires for notify-send (Issue #13)

v3.0.2

  1. Fixes version check for Mac OS X Yosemite

v3.0.0

  1. Updates terminal-notifier to version 1.6.0; adding support for appIcon and contentImage
  2. Removes parsing of output sent from notifier (Notification Center)

NPM downloads

License

MIT License

Keywords

FAQs

Last updated on 05 Aug 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc