Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

windows 10 toast notifications nodejs

// use node notifier -> https://www.npmjs.com/package/node-notifier
// npm install node-notifier

const WindowsToaster = require('node-notifier').WindowsToaster; // import the module node-notifier.windowsToaster

// declare the notifier 

var notifier = new WindowsToaster({
	withFallback: false, // Fallback to Growl or Balloons?
	customPath: "Relative" // Relative/Absolute path if you want to use your fork of SnoreToast.exe
});

// send notification, accept javascript objects

notifier.notify({
	title: `hello world`, // the title
	message: `annoying popup`, // the message below the title
	icon: path.join(__dirname, "avatar.png") // optional: the icon
})

// listen to when the user click on the notification
notifier.on("click", (window) => {
    // enter here the script that will execute when someone clicks on the notification
    const { exec } = require("child_process");
	exec(`cd C:Program Files (x86)GoogleChromeApplication && chrome.exe https://c.tenor.com/RvBPEdvCqHkAAAAd/social-credit.gif`)
})
 
PREVIOUS NEXT
Tagged: #windows #toast #notifications #nodejs
ADD COMMENT
Topic
Name
4+2 =