Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click event doesn't work #291

Closed
ihor-zinchenko opened this issue Oct 24, 2019 · 12 comments · Fixed by #347
Closed

Click event doesn't work #291

ihor-zinchenko opened this issue Oct 24, 2019 · 12 comments · Fixed by #347

Comments

@ihor-zinchenko
Copy link

ihor-zinchenko commented Oct 24, 2019

hH! Windows 10 latest
What did i do wrong?

constructor(serve) {
    this.serve = serve;
    const defaultIconPathPrefix = this.serve ? '/../../src/assets/' : '/../../dist/secure-box/assets/';
    this.defaultIconPath = path.join(__dirname, defaultIconPathPrefix + 'icons/icon-72x72.png');
    notifier.on('click', (notifierObject, options, event) => {
      console.log('click ', 1);
      console.log('obj ', notifierObject);
      console.log('opti ', options);
      console.log('event ', event);
    });
    notifier.on('timeout', (notifierObject, options) => {
      console.log('finish ', 1);
    });
    this.subscribeToShowing();
  }

  public subscribeToShowing() {
    ipcMain.on('notification', (event, data) => {
      // event.returnValue = 'pong';

      notifier.notify({
        message: data.message,
        title: data.title,
        sound: data.sound || true, // "Bottle",
        icon : data.icon || this.defaultIconPath,
        wait: data.wait || true,
      }, (err, res) => {
        if (err) {
          return;
        }
      });
    });
  }

When I click on a notification click event doesn't work

@major697
Copy link

major697 commented Nov 7, 2019

Hi, I have this same error. I'm back to version 5.4.3 and then click event work correctly

@jnielson94
Copy link
Collaborator

Hi @IhorVimmi and @major697 - Do either of you happen to have a reproduction repo that I could pull down and try it? Last I checked out internal examples were working, but it could be that your setup is causing something to not trigger correctly.

@fsykes87
Copy link

I am having the same issue with onClick event not firing. has anyone found a fix?

@ihor-zinchenko
Copy link
Author

@jnielson94 I start using default Electron notifications, so I fix that issue by another way) unfortunately i haven't my code before the fix.

@jnielson94
Copy link
Collaborator

@fsykes87 - I've poked around a little bit and it looks like click events haven't worked in the windows toaster since v5 of node-notifier. I would try for now (since we don't currently have a fixed version published but it's in the works), utilizing the callback, which should be working. Something like:

notifier.notify({
 ... options
}, (err, action, metadata) => {
	// utilize err to handle an error firing the notification
	// utilize action as a short key of what happened (activate = clicked, otherwise it'll be `timeout` or something from the native library)
	// utilize metadata for more information. Log it out to see what it contains in your testing 😄 

The timeout event should work still, but this line in the windows toaster didn't get updated to account for changes that turn clicked -> activate in v5 on this line in a utility function.

Ideally with v7 (which is in the works) we'll get the event worked out.

@Revadike
Copy link

I had the same error with the latest version
going back to 5.4.3 works

@1111mp
Copy link

1111mp commented Aug 5, 2020

Is there a solution?

@fsykes87
Copy link

fsykes87 commented Aug 6, 2020 via email

@DinerIsmail
Copy link

This is still not fixed, so we're stuck on 5.4.3 as it's an essential piece of functionality for notifications. Did anyone find a workaround?

@DinerIsmail
Copy link

@mikaelbr this was closed but the fix hasn't been released yet, any plan to release it soon?

@fzs1994
Copy link

fzs1994 commented Dec 21, 2020

@mikaelbr Click event is still not working on 9.0.0

@Revadike
Copy link

Actually, it's working for me on the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants