node-notifier icon indicating copy to clipboard operation
node-notifier copied to clipboard

snoretoast with custom appid: result ist not passed to callback (electron)

Open NaridaL opened this issue 4 years ago • 17 comments

I don't know if this is specific to electron...

In any case, here's a minimal repro:

https://github.com/NaridaL/electron-node-notifier-bug

image

image

NaridaL avatar May 23 '20 18:05 NaridaL

@NaridaL I am also facing the same issue

joydeep33 avatar Aug 04 '20 08:08 joydeep33

I no longer have easy access to Windows. Any help with debugging, implementation, and QA would be greatly appreciated.

mikaelbr avatar Aug 10 '20 20:08 mikaelbr

I am facing the same issue, too.

I found if you assigned an 'appId' property on options, like this

notifier.notify(
  {
     ...
    appID:  'com.some.id' 
    .... 
  },

When you clicking on notification popup, you won't received any response from net.createServer : https://github.com/mikaelbr/node-notifier/blob/2d3927b200a0fd1721e8b8ad59f84f383d3f0e0a/lib/utils.js#L559

But i don't know why.

Hope it helps.

KaiSheng714 avatar Nov 17 '20 10:11 KaiSheng714

Facing the same issue.

tomboolean avatar Jan 15 '21 01:01 tomboolean

Noticed this from https://github.com/KDE/snoretoast :

If you want to brand your notifications you need to create the application startmenu entry with snoretoast.exe --install "MyApp\MyApp.lnk" "C:\myApp.exe" "My.APP_ID". This appID then needs to be passed to snoretoast.exe with the `--appID`` parameter.

We may need to use this method to set the appid versus just the setappmodelid method

tomboolean avatar Jan 17 '21 13:01 tomboolean

This actually completely break the interactive notification functionality of this library, which is the only reason to use it over native electron notifications..

Either we show notifications with SnoreToast image+text or we can't respond to any button click

Araxeus avatar Apr 08 '21 14:04 Araxeus

Use the shell.writeShortcutLink to create or update your application shortcut with the required properties, which are the correct appID and the toastActivatorCLsid.

NunoCuradoFuze avatar May 06 '21 15:05 NunoCuradoFuze

@NunoCuradoFuze how do you find and set toastActivatorClsid? could you give some more details please?

Araxeus avatar May 06 '21 15:05 Araxeus

Yes this is my question too!

On Thu, May 6, 2021 at 8:13 AM Araxeus @.***> wrote:

@NunoCuradoFuze https://github.com/NunoCuradoFuze how do you find and set toastActivatorClsid? could you give some more details please?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mikaelbr/node-notifier/issues/332#issuecomment-833603070, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABU6Y2PA4B2EPEDQ6HCZTVLTMKWZPANCNFSM4NIRYARQ .

--

Ana Tomboulian

*CTO | *peerlogic

480 | 561.1554

@.*** | https://www.linkedin.com/in/anatomboulian/

tomboolean avatar May 06 '21 15:05 tomboolean

Look for Shell API electron. Also for more information about Class ID and ToastActivator you should check microsoft documentation.

Example on how to use the writeShortcutLink to update your current shortcut:

let shortcut = path.join(process.env.APPDATA, 'Microsoft', 'Windows', 'Start Menu', 'Programs', '#appName.lnk'); let res = shell.writeShortcutLink(shortcut, 'update', { target: process.execPath, appUserModelId: "#appIDD", toastActivatorClsid: "#Use a valid CLSID" }); if (res) { console.log('Shortcut created successfully', 'success'); } else { console.log('Failed to create the shortcut', 'danger'); }

NunoCuradoFuze avatar May 06 '21 16:05 NunoCuradoFuze

@NunoCuradoFuze thanks for that, but how do I specify to node-notifier whats the registered CLSID? how would node-notifier / snoreToast know which clsid to look for?

could you maybe share how you did it? I can't find any documentation about using it with electron :(

without CLSID it all seems to work well - except the response from actions on notifications is always undefined

Araxeus avatar May 06 '21 16:05 Araxeus

For @tomboolean and anyone else facing the same issue:

check out https://github.com/mikaelbr/node-notifier/pull/347#issuecomment-834960709

@DuBistKomisch has completely fixed the problem in his branch ! 😁

Araxeus avatar May 08 '21 13:05 Araxeus

@Araxeus amazing! I will have to go thank him!

tomboolean avatar May 10 '21 14:05 tomboolean

I believe SnoreToast internally register the callback with the toast activator clsid "eb1fdd5b-8f70-4b5a-b230-998a2dc19303". So if you have created your own shortcut, all you have to do is to update shortcut properties with this CLSID and appID, using electron shell api.

If I understand correctly, #347 points to a scenario where you used SnoreToast to install the shortcut. When using the notifier without appID, it would prompt the notification with the SnoreToast text and image. With appID the action buttons wouldn't work if I am correct.

NunoCuradoFuze avatar May 13 '21 10:05 NunoCuradoFuze

@NunoCuradoFuze

I believe SnoreToast internally register the callback with the toast activator clsid "eb1fdd5b-8f70-4b5a-b230-998a2dc19303". So if you have created your own shortcut, all you have to do is to update shortcut properties with this CLSID and appID, using electron shell api

I still don't think it possible that you use both your appID and have working buttons currently, snoretoast seems to just ignore buttons if you have a custom appID, without writing to any pipe.


The fix mentioned works without having the need to specify a CLSID or install shortcut from snoretoat (can specify appID, and your app text and image will show up and actions buttons will work)

this works with shortcuts installed from shell.writeShortcutLink or other methods (Electron-Builder shortcuts)

You just need to have the right appID in the shortcut and you can forget about clsid

Araxeus avatar May 13 '21 14:05 Araxeus

any update guys?

abdulghanitech avatar Oct 27 '21 13:10 abdulghanitech

sadly still waiting for https://github.com/KDE/snoretoast/pull/15 to get merged and published.. Maybe ask that question there

Araxeus avatar Oct 27 '21 18:10 Araxeus

There's actually a pretty easy way to fix this, we just didn't implement SnoreToast well enough:

Here's a guide: https://github.com/mikaelbr/node-notifier/issues/424

Araxeus avatar Jan 07 '23 03:01 Araxeus