node-notifier
node-notifier copied to clipboard
Windows 10 not getting toasts
I installed the package last night and just ran the simple example to test it out and it worked great. The notifcations showed up. Then the next time I tried to run the script it no longer works at all.
const notifier = require('node-notifier');
// String
notifier.notify('Message');
Going to the notifications settings in Windows 10 I see the toast
entry and everything is enabled. Banners and all of it.
I can manually go to node_modules\node-notifier\vendor\toaster\toast.exe
and run the executable directly from the command line and it will work just fine.
I've tried targeting only the WindowsToaster
and setting the custom path
const WindowsToaster = require('node-notifier/notifiers/toaster');
new WindowsToaster().notify("Message");
and
const WindowsToaster = require('node-notifier').WindowsToaster;
var notifier = new WindowsToaster({
customPath: './vendor/toaster/toast.exe' // Relative path if you want to use your fork of toast.exe
});
Neither of these things worked. I'm just so confused it worked perfectly the first time I ran the code now it just doesn't work at all. I've tried reinstalling all the packages.
Might there be an issue with Windows on this? AFAIK, you have to have a shortcut of the toaster vendor in your Windows menu for you to allow to send messages. Have you removed that? It should be added automatically, initially (and may explain why it worked the first time).
Also, make sure to check your notification settings if the notifications for toaster.exe is turned off.
In the master-branch we've changed how toasters work. So please try npm i mikaelbr/node-notifier
and see if that works as expected.
Root cause is #160
Tested yesterday on Windows 10 and nothing showed up (never, not first time, not other times). Same code is working on Linux (KDE) flawlessly.
I think this is due to some register app in notification issue causing it some times to fail initially and other times to work. Need to investigate what the root cause is, but it seems to work on fresh windows installations – so maybe try to remove node-notifier, snoretoast etc from the notification list in the Control Panel.
I think the windows push notification is canceled by node-notifier if there is no appId (as far as i can remember).
But i think i found out something that can help you.
In your package.json define your appId
"build": {
...
"appId": "org.whatever.application-id",
...
Then when you notify pass your appId as well:
notifier.notify({
appName: 'org.whatever.application-id',
title: 'Whatever',
message: `whatever`,
sound: false,
wait: true
}, (err) => {
if (err) {
console.error('Snoretoast error: ', err);
}
});
On first though, i was expecting this to work, but it does not yet (in development mode at least). You have to package then INSTALL your application on our computer first. In my case, i'm using electron, so i packaged up with electron-builder then installer the setup.exe. Now notifications should work in development mode as well (as long as you don't change the appId). It seems that Windows is registering your appId or something else when you first install our app, and thus allow ou to push notifications.
For information, now it's appID
(and not "appName") that should be set.
Sorry my exemple doesn´t run corretitly(Iam Angolano and i dont speak inglish very well) but i want sô much learn Elctron js
I have also the same problem after update windows :(, sometimes it shows now but before the update, it shows properly