'Pass values to callback functions of action buttons in notification in node/electron application? Also callback functions not working after timeout

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);
});


Solution 1:[1]

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:

On Windows 10, a shortcut to your app with an Application User Model ID must be installed to the Start Menu. This can be overkill during development, so adding node_modules\electron\dist\electron.exe to your Start Menu also does the trick. Navigate to the file in Explorer, right-click and 'Pin to Start Menu'. You will then need to add the line app.setAppUserModelId(process.execPath) to your main process to see notifications.

https://www.electronjs.org/docs/latest/tutorial/notifications#:~:text=On%20Windows%2010,to%20see%20notifications

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kendra Wannamaker