Question: My goal is to send [Gmail-style desktop notifications](https://support.google.com/mail/answer/1075549?hl=en) in Chrome or Firefox from a web app (let's call it X) that is NOT currently open in the browser, without requiring the user to install an app or extension. It's okay if the user needs to grant permission to receive notifications from X, and it's okay if the browser needs to be open for the notification to appear, as long as X doesn't need to be open in the browser. A solution that doesn't require any browser window to be open would also work.

I just spent the day digging into this, and so far I *think* I've learned:

* Since OSX Mavericks, it has been possible to do this in Safari 7+ via [Safari Push Notifications](https://developer.apple.com/notifications/safari-push-notifications/).
* The [Web Notifications API](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Using_Web_Notifications) works in Chrome/Firefox, but requires the user's browser to be open to X.
* [Twitter](https://blog.twitter.com/2014/stay-connected-with-notifications-on-twittercom) sends similar web notifications without asking the user for permission first, but requires the user's browser to be open to Twitter.
* There are lots of references to possible [Growl](https://stackoverflow.com/questions/6537558/growl-notifications-how-to-push-growl-notifications-from-a-website/6540973#6540973) implementations, but as far as I can tell, all of them require the user to install Growl and/or a Growl-enabled app to work.

I could be wrong about any of my statements above - I'd love to hear it! - and I'm open to any other solution too. Any ideas?

Thanks for reading.

Answer: 
You can send push notifications even when your web page is not active using [Service Workers](https://github.com/slightlyoff/ServiceWorker/blob/master/explainer.md), the [Notification API for service workers](https://notifications.spec.whatwg.org/#service-worker-api) and the [push API](https://w3c.github.io/push-api/) for server-initiated notifications (or [scheduled notifications](http://www.w3.org/TR/web-alarms/)).

As of June 2016, Service Workers are supported in Chrome, Firefox and Opera. See the status at <https://jakearchibald.github.io/isserviceworkerready/>

See the following links for related discussions, status of implementation and specifications.

* Service workers are [enabled by default since Chrome 40](https://code.google.com/p/chromium/issues/detail?id=364627), [Firefox 33](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers), and Opera 24. See the [HTML5Rocks tutorial](http://www.html5rocks.com/en/tutorials/service-worker/introduction/) and [MDN](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker_API).
* Push notifications: [Chrome 42+](https://www.chromestatus.com/feature/5480344312610816), [Firefox 44+](https://support.mozilla.org/en-US/kb/push-notifications-firefox)
You can do exactly what you are looking for using the W3C **Push API**.

If you want to build everything from scratch I suggest to start reading [this tutorial by Google](https://developers.google.com/web/updates/2015/03/push-notifications-on-the-open-web). It is for Chrome, but Firefox works in [a very similar way](https://hacks.mozilla.org/2016/01/web-push-arrives-in-firefox-44/).

However it's a lot of work and the "standard" is still evolving: I suggest that you use a service like [Pushpad](http://pushpad.xyz) (I am the founder).