Live data from Hacker News

Push.js – A minimalist JavaScript library for desktop notifications

github.com

21–30 of 40 posts

Re: Push.js – A minimalist JavaScript library for desktop notifications

#21
post #6

super nifty and really useful, does it require https ?

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.

Re: Push.js – A minimalist JavaScript library for desktop notifications

#22
post #6

super nifty and really useful, does it require https ?

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.

Presumably grandparent post was paranoid that http websites have some lower status in terms of being able to send notifications. Not a likely scenario, but not an entirely unreasonable question.

Re: Push.js – A minimalist JavaScript library for desktop notifications

#23
post #6

super nifty and really useful, does it require https ?

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.

https://developers.google.com/web/updates/2015/03/push-notif...

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.

Re: Push.js – A minimalist JavaScript library for desktop notifications

#24
post #22

Earlier quoted context omitted.

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.

Presumably grandparent post was paranoid that http websites have some lower status in terms of being able to send notifications. Not a likely scenario, but not an entirely unreasonable question.

The browser push APIs do require HTTPS, since browsers refuse to install service workers otherwise (which is required for them to function...). That said, the demo is hosted over plain HTTP, and seems to work for me (Chrome 50, Linux).

Re: Push.js – A minimalist JavaScript library for desktop notifications

#25
post #8
post #5

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...

See also https://hacks.mozilla.org/2016/01/web-push-arrives-in-firefo... WebPush is (going to be) an IETF standard: https://datatracker.ietf.org/wg/webpush/documents/

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

Re: Push.js – A minimalist JavaScript library for desktop notifications

#26
post #23

Earlier quoted context omitted.

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.

https://developers.google.com/web/updates/2015/03/push-notif... 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.

So, I think there is some misunderstanding here. What you've linked here are Push notifications, which yes, go through GCM and do require web service calls. This JS library is doing Desktop notifications, which afaik, are an entirely different thing, and are strictly limited to "within the context of the active page."

Re: Push.js – A minimalist JavaScript library for desktop notifications

#27
post #22

Earlier quoted context omitted.

Presumably grandparent post was paranoid that http websites have some lower status in terms of being able to send notifications. Not a likely scenario, but not an entirely unreasonable question.

The browser push APIs do require HTTPS, since browsers refuse to install service workers otherwise (which is required for them to function...). That said, the demo is hosted over plain HTTP, and seems to work for me (Chrome 50, Linux).

These are not actual "push" notifications, they are desktop notifications. Different functionality, and no service workers.

Re: Push.js – A minimalist JavaScript library for desktop notifications

#28
post #20

Earlier quoted context omitted.

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.

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.

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.

Re: Push.js – A minimalist JavaScript library for desktop notifications

#29
post #3

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);

Usually chrome requires a service worker for notifications and I don't see one in this library. Anybody else get this working with chrome?

Re: Push.js – A minimalist JavaScript library for desktop notifications

#30
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.
Post reply on HN