How to implement desktop notification?


Is it possible to implement desktop notification like Gmail in Electron?
After exiting the app is it possible to listen to a service and generate notification?

Any example code?


Check out the tray object documentation. It includes a sample.

For a real example, check out the source for gitify. Looking at the main.js, it looks like it runs in the notification area/task bar without a main window and pumps out notifications. This is probably what you’re looking to do, right?


You can also do it using Polymer using the Google push notification element.


Didn’t fully get it… though I found the displayBalloon() method in the documentation, this one is just available on Windows. Would like to display ‘desktop notifications’ on OS X and (Ubuntu) Linux as well…

Any ideas?


Ok, might be possible with the standard Web Notifications (… Have to check this later.


Ok, seems that the HTML5 notification API is working on OS X, but not on Windows. I therefore made a special ‘displayBalloon’ call when running on Win32.

On OS X you can use the Notification object from your renderer like this:

var notify = new Notification('title', { body: 'body', icon: 'assets/icon.png' });


You could also use node-notifier which works on Linux, OSX and Windows >= 8.

It also looks like the HTML5 notification API has been fixed on Windows.


Sorry if this conversation is old, and perhaps this is solved now, but seems like you could use a tray icon, then when an event occurs trigger ‘chrome less’ window and use the screen resolution max - size of your window for notification to place it in the proper corner, and use a timer to make it go away, or a click event to make it disappear.

If I’m missing the point, let me know.