node-notifier
node-notifier copied to clipboard
Terminal Click Event With Custom terminal-notifier.app
when I install the newest package: npm install mikaelbr/node-notifier. And I found the terminal.app icon is default.So I replace node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app to my custom .app with my custom icon.
It worked with new icon, but the click event doesn't work which is confused.
Have seen a few issues before, but couldn't found a useful solution, I need help...
In Mac, I also encountered the same problem,and If the click prompt is too fast, or it is not the current app, an error will be prompted.



const isDev = require("electron-is-dev");
const fixPath = () => {
var icon
var contentImage
var open
if(isDev){
icon = path.join(__dirname, 'a.png')
contentImage = path.join(__dirname, 'a.png')
open = path.join(__dirname, 'a.png')
}else{
icon = path.join(__dirname, "/static/icon.png");
contentImage = path.join(__dirname, "/static/icon.png");
open = path.join(__dirname, "/static/icon.png");
}
return {
icon,
contentImage,
open
}
}
let {icon, contentImage, open} = fixPath()
ipcMain.on("notify", (evt, data) => {
const { title, message } = data;
console.log("notify:", title, message);
notifier.notify({
title,
message,
wait: true,
icon: icon,
contentImage: contentImage,
open: open,
},(err, res) => {
if (err) {
console.log("error:", err);
}
});
// 点击之后
// After clicking on
notifier.on('click', function (notifierObject, options, event) {
console.log(notifierObject, options, event)
// Triggers if `wait: true` and user clicks notification
});
// 自动消失之后
// After it goes away automatically
notifier.on('timeout', function (notifierObject, options) {
console.log(notifierObject, options)
// Triggers if `wait: true` and notification closes
});
});