[solved] Notifications only work from packaged .app file


I’m trying to get notifications to work with Electron. I found this example which looks exactly like what I want but unfortunately it (the example) does not work on my machine.

I’m running OS X El Capitan so I’m suspecting that this could be the issue but I don’t really know for sure. In Chrome I can successfully display a notification doing the following in the console:


followed by

new Notification("test")


It looks like the Notification class is part of Chromium:

I suspect that the reason they’re different is because you’re using El Capitan. I’m using an experimental branch of Atom that uses Electron v0.30.6 on Mac OS X 10.10.5 and this is what new Notification("test") looks like when I run it from the console in Atom:


Thanks for the quick reply @leedohm!
When using Atom on 10.11 I can also trigger a notification using the console.
On Slack @paulcbetts said that the example works on his 10.11 machine.

I’m not sure what else could be going wrong here.

$ electron -v


Oh! It works once I packaged the app and ran it via it’s own .app file — is that expected?


Unfortunately, I have no idea. I haven’t worked with Electron itself lately.


So this doesn’t seem to be caused by 10.11 — @paulcbetts runs 10.11 and it’s working for him.

Now I’m thinking that this might be an OS X settings issue or at least not something related to electron but looking at the “Notifications” settings I cant see anything that seems relevant. Can you think of other settings that could cause similar behaviour?

Any obvious things I could have missed?


Perhaps it is a sandboxing thing? Apple prevents notifications from code that doesn’t look like an app maybe?


The cause was that I was starting electron from inside tmux without using a utility like reattach-to-user-namespace.

In one situation this even led to windows being shown in Expose but any attempt at focusing that window failed.

After adding the following to my .tmux.conf I can start electron from inside tmux and trigger notifications from the console.

set-option -g default-command "reattach-to-user-namespace -l fish"


@martinklepsch thank you so much for posting this! I have been scouring the documentation to figure out why notifications wouldn’t work in development. I too was also running tmux but never would have expected that to be the cause.