How to implement desktop notification?


#1

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?


#2

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?


#3

You can also do it using Polymer using the Google push notification element.
https://elements.polymer-project.org/elements/platinum-push-messaging


#4

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?


#5

Ok, might be possible with the standard Web Notifications (http://caniuse.com/#search=notification)… Have to check this later.


#6

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:

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

#7

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.


#8

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.