
Push.js – A minimalist JavaScript library for desktop notifications - Nickersoft
https://github.com/Nickersoft/push.js
======
echeese
I hate to be pedantic but these are not push notifications. Those are the ones
that can be sent even if the webapp is closed, for example, this Chrome demo:
[https://developers.google.com/web/fundamentals/getting-
start...](https://developers.google.com/web/fundamentals/getting-started/push-
notifications/?hl=en)

~~~
jvehent
See also [https://hacks.mozilla.org/2016/01/web-push-arrives-in-
firefo...](https://hacks.mozilla.org/2016/01/web-push-arrives-in-firefox-44/)

WebPush is (going to be) an IETF standard:
[https://datatracker.ietf.org/wg/webpush/documents/](https://datatracker.ietf.org/wg/webpush/documents/)

~~~
andrewstuart2
Yikes, that really seems like abuse of HTTP/2 semantics to me. My
understanding has always been that server push in HTTP/2 is only intended to
prime the client cache for requests you know they're about to (or likely to)
make. [1]

> Pushed responses are always associated with an explicit request from the
> client.

I'd rather see additional frame types defined that allow for bidirectional
communication (i.e. websockets 2.0) than overriding and conflating the
PUSH_PROMISE frame type.

[1]
[https://tools.ietf.org/html/rfc7540#section-8.2](https://tools.ietf.org/html/rfc7540#section-8.2)

------
bikamonki
I think you may be confusing push notifications with browser notifications?

------
philfreo
Any reason why you couldn't instead have an optional drop-in Shim that allows
developers to use the current/modern HTML5 Notifications API syntax, where the
shim simply adds supports to older/other browsers? I hate introducing
additional APIs if it's not necessary. In the future when the browsers you
care about support the Notifications API it's easiest to simply remove the
shim.

------
Nickersoft
Quick apology for confusing the terms "push notification" and "desktop
notification". I forgot "push" usually refers to sites that use service
workers to send notifications to the desktop regardless of whether the browser
window is open. This library requires the window remain open for the
notification to be shown.

------
TheAceOfHearts
In the web app I work on, we have a toast component that we use to show the
user status messages. It's usually used for showing error messages. I've been
aware of desktop notifications being around or a couple years now, but I
haven't used em.

What guidelines or general rule of thumb do you use when deciding if something
is worth a notification?

------
acbabis
I just downloaded this and made a 1-liner to try it out. Really cool. Worked
just fine in FF. Not sure why it didn't do anything in Chrome on Mac.

> setInterval(function() { Push.create('Hi') }, 2000);

~~~
K-Wall
I too had this issue. I appears that notifications don't show in full screen
mode. When I returned Chrome to a windowed app on my Mac the notifications
appeared.

~~~
Nickersoft
I think I ran into the issue before as well.. however, I think that's an issue
with how Chrome handles its notifications. I don't think there's anything in
the library that could cause this behavior. A known issue is that the library
is currently broken in Safari. I will investigate why when I have some free
time.

------
jflowers45
I'm a little bit new to the desktop notifications game, but it would be cool
to know how this compares/relates to something like roost

------
ramon
Nice project, I liked the fact that it has a fallback to older browser
versions, will test it later.

------
philippnagel
Is there a similar library for mobile?

~~~
shortstuffsushi
Does mobile have a comparable feature? Native Push Notifications are an
entirely different beast; afaik, there is no way to have browser type
notifications like this.

~~~
Fogest
Chrome on Android does support push notifications from the browser. Facebook
makes use of this and you can actually get push notifications from Facebook
without using their app. Facebook requests in the Chrome browser to use
notifications and then you can receive them without even having the browser
app open.

~~~
shortstuffsushi
For push notifications, yes, but these are "browser / desktop" notifications,
which only show up while the application is running. It's possible this works
on mobile with the app running in the background, but I haven't seen it
before.

------
SimeVidas
No demo?

~~~
Nickersoft
Sorry, I meant to mention the demo is at
[http://nickersoft.github.io/push.js/demo.html](http://nickersoft.github.io/push.js/demo.html).

------
abimaelmartell
Not working on Safari.

~~~
nodesocket
Does not seem to work locally using Chrome 50.0.2661.102 (64-bit) either. Not
a good sign.

~~~
softawre
> eighter

Niner one niner five copy that.

~~~
nodesocket
I type good.

~~~
chrisper
You should write a JavaScript library for typing!

------
adalyz
super nifty and really useful, does it require https ?

~~~
shortstuffsushi
Why would it require HTTPS? This is a javascript library that allows you to
hook into a native browser function (showing desktop notifications). There are
no web services involved.

~~~
adalyz
[https://developers.google.com/web/updates/2015/03/push-
notif...](https://developers.google.com/web/updates/2015/03/push-
notifications-on-the-open-web?hl=en)

Why does this require HTTPS? How do I work around this during development?
Service workers require secure origins to ensure that the service worker
script is from the intended origin and hasn’t come about from a man-in-the-
middle attack. Currently, that means using HTTPS on live sites, though
localhost will work during development.

~~~
martijndwars
To answer the "how do I work around this during development": non-HTTPS is
permitted on localhost (this is at least the case in Chrome). The spec also
hints at this ([https://w3c.github.io/push-api/#security-and-privacy-
conside...](https://w3c.github.io/push-api/#security-and-privacy-
considerations)). But, as has already been mentioned, this is about desktop
notifications and not web push.

