In a node/electron application, used node-notifier to show notification, working great. Then, added buttons 'ok' and 'cancel', and their respective callback functions. callback functions are also working as expected until users misses any notification and notification times out. After notification is timed-out, it moves to the (in case of windows 10) notification sidebar, and shows the title and message of the notification, buttons are also visible, but buttons do not work, not even console.log.
Second issue is the I am unable to find a way to pass argument/value to the callback functions. Below is the code:
const notifier = require('node-notifier')
notifier.notify({
title: title,
message: message,
icon: path.join(__dirname, 'logo.jpg'),
actions: ['Ok','Cancel'],
wait: true,
},function(err, response, metadata){
// Response is response from notification
// Metadata contains activationType, activationAt, deliveredAt
console.log(err, response, metadata);
});
// Notifier Default events
notifier.on('click', function(notifierObject, options, event){
// Triggers if `wait: true` and user clicks notification
console.log('"Clicked" on notification' , notifierObject, options, event);
});
// Notifier Button actions
notifier.on('ok', function(notifierObject, options, event){
console.log('"OK" pressed', notifierObject, options, event);
});
notifier.on('cancel', function(notifierObject, options, event){
console.log('"Cancel" pressed', notifierObject, options, event);
});
It's probably too late to help the question asker, but if anyone else runs into this question:
I suspect your first issue is related to this:
https://www.electronjs.org/docs/latest/tutorial/notifications#:~:text=On%20Windows%2010,to%20see%20notifications