Send Notifications Through Node.js App! 🔥

In this article, we are going to learn how we can create notifications/reminder in Windows/ MacOS with your Node.js app.

Approach:

To make a notification through our node app, we are going to use node-notifier package. It is already a qui…


This content originally appeared on DEV Community and was authored by Sujeet Gund

In this article, we are going to learn how we can create notifications/reminder in Windows/ MacOS with your Node.js app.

Sample Shots 1

Approach:

To make a notification through our node app, we are going to use node-notifier package. It is already a quiet popular package with more than 9M weekly downloads!

About this package:
Package Size Package Downloads

Steps:

  1. Do the initial setup for node app.

  2. Install the package:

yarn add node-notifier

or

npm install node-notifier
  1. Quickstart with this short code: add this code in your index.js
const notifier = require('node-notifier');
// String
notifier.notify('Message');

// Object
notifier.notify({
  title: 'My notification',
  message: 'Hello, there!'
});

You can further add more custom option in it like icon, wait for user action, timeout, reply etc.

const notifier = require('node-notifier');
const path = require('path');

notifier.notify(
  {
    title: 'My awesome title',
    message: 'Hello from node, Mr. User!',
    icon: path.join(__dirname, 'coulson.jpg'), // Absolute path (doesn't work on balloons)
    sound: true, // Only Notification Center or Windows Toasters
    wait: true // Wait with callback, until user action is taken against notification, does not apply to Windows Toasters as they always wait or notify-send as it does not support the wait option
  },
  function (err, response, metadata) {
    // Response is response from notification
    // Metadata contains activationType, activationAt, deliveredAt
  }
);

notifier.on('click', function (notifierObject, options, event) {
  // Triggers if `wait: true` and user clicks notification
});

notifier.on('timeout', function (notifierObject, options) {
  // Triggers if `wait: true` and notification closes
});

đź’ˇ Note: This package has its own system requirements.

  • macOS: >= 10.8 for native notifications. _
  • Linux: _notify-osd or libnotify-bin installed (Ubuntu should have this by default) _
  • Windows: >= 8, or task bar balloons for Windows < 8.
  • And if not met any requirement then it will use Growl.

More know about this package on:

Hit like if you found this article interested and feel free to ask queries!

Also read:

How to send SMS with Nodejs App
Awesome VS Code Customizations


This content originally appeared on DEV Community and was authored by Sujeet Gund


Print Share Comment Cite Upload Translate Updates
APA

Sujeet Gund | Sciencx (2022-06-28T05:10:42+00:00) Send Notifications Through Node.js App! 🔥. Retrieved from https://www.scien.cx/2022/06/28/send-notifications-through-node-js-app-%f0%9f%94%a5/

MLA
" » Send Notifications Through Node.js App! 🔥." Sujeet Gund | Sciencx - Tuesday June 28, 2022, https://www.scien.cx/2022/06/28/send-notifications-through-node-js-app-%f0%9f%94%a5/
HARVARD
Sujeet Gund | Sciencx Tuesday June 28, 2022 » Send Notifications Through Node.js App! 🔥., viewed ,<https://www.scien.cx/2022/06/28/send-notifications-through-node-js-app-%f0%9f%94%a5/>
VANCOUVER
Sujeet Gund | Sciencx - » Send Notifications Through Node.js App! 🔥. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/06/28/send-notifications-through-node-js-app-%f0%9f%94%a5/
CHICAGO
" » Send Notifications Through Node.js App! 🔥." Sujeet Gund | Sciencx - Accessed . https://www.scien.cx/2022/06/28/send-notifications-through-node-js-app-%f0%9f%94%a5/
IEEE
" » Send Notifications Through Node.js App! 🔥." Sujeet Gund | Sciencx [Online]. Available: https://www.scien.cx/2022/06/28/send-notifications-through-node-js-app-%f0%9f%94%a5/. [Accessed: ]
rf:citation
» Send Notifications Through Node.js App! 🔥 | Sujeet Gund | Sciencx | https://www.scien.cx/2022/06/28/send-notifications-through-node-js-app-%f0%9f%94%a5/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.