Electron Notifications Help


Hey everyone,

I am new to Electron and to the Atom Discussion page. I had a question regarding notifications through Electron. I have been trying to implement a local notification to test how the look and feel of notifications are in the framework. I keep receiving an error saying:

‘notifications is not defined at EventEmitter..’

Would anyone be able to post up a sample code of how a basic local notification works? Thanks for your help and time, I would really appreciate it.



Which OS are you working on?
Notifications isn’t really supported for Windows just yet, and it’s somewhat limited for Linux, see this issue:

However, someone on this other issue says he found a way, using ipc:

  ipc = require('ipc');
  Notification = function(title, options) {
    ipc.send('notify', {title: title, options: options});
  Notification.permission = 'granted'

Not sure, worth trying?


Hey batjko,

Thanks for getting back to me. I will implement this and see what happens. I am running OS X


in which case you should be able to use the Web Notifications API:


Thanks for that. Im still receiving an error saying that Notification is not defined. Shouldn’t this already be built into the electron pre-built package? Thanks in advance


Could you show the code you’re using? It’s much easier for others to help you debug that way :wink:


haha yes I can!

var app= require(‘app’);

app.on(‘ready’, function(){

var BrowserWindow = require(‘browser-window’);
var win = new BrowserWindow({ width: 1150, height: 1920, show: false, ‘node-integration’: false });
win.on(‘closed’, function() {
win = null;
function spawnNotification (theBody, theIcon, theTitle){
var options = {
body : theBody,
icon : theIcon
var n = new Notification (theTitle, options);
spawnNotification(‘Test Notification’,’/Users/alecdilanchian/Desktop/test1/sightplan.png’, ‘Hello World!’);


Am I calling the function in the correct place? I really appreciate all the help


It looks like you are trying to call the notification from the main process but I’m not sure that the Web Notifications API is available outside the renderer process.


Okay got it. Im going to play around with that and see if anything changes. Thanks john!


I think @john is right. You can read more about the separation of main process vs. renderer process in this article.


Thanks for everyones help. It seems like I will need to look into the ipc module. Thanks again!

Im curious if you guys know of any sample codes that I can look into? I’ve been looking everywhere for this information haha.


i have managed to sort the Web API version to work ok.

Here is a ES2015 class i created, and here is how i implemented it, hopefully this might help, but did not require it via the ipc module.

As mentioned before, place this with in your browser js files and not the main process.


Thanks so much for this. I will take a look.