f



Chrome and Push API

Web application for providing audio content to users. It's not officially l=
aunched yet.

I started using the Push API so that when a user finds audio content they l=
ike, they can subscribe to that content provider and get notifications when=
 that provider uploads new content.

It is working fantastically with FireFox 49.

The subscription is activated by a button inside a div. Initial state of bu=
tton is disabled.

on pageload, JS checks for "serviceWorker" in navigator and then checks for=
 "showNotification" in ServiceWorkerRegistration.prototype and then checks =
for Notification.permission !=3D=3D "denied" and finally checks for "PushMa=
nager" in window

If any of those tests fail the button remains disabled and the div has its =
display set to hidden.

So the button to subscribe should only be available on platforms that actua=
lly support the feature.

In FireFox everything is working both on desktop browser and on FireFox for=
 Android.

I don't have access to Chrome for Desktop, Google doesn't support Chrome on=
 CentOS 7 which is my desktop.

But Chrome on Android, the subscribe button is shown and activated indicati=
ng Chrome on Andoid supports what is needed - but it doesn't work.

From looking around the web, I got the impression from several sources that=
 a manifest.json is required for Push API to work for Chrome (which is odd,=
 the W3C specification says nothing about needing that) so I created and po=
pulated a manifest.json and made the link tag pointing to it.

Chrome for Android still won't allow push subscription.

Does anybody know what is going on? What chrome wants?

The service worker and JavaScript the pages use to install the service work=
er are JSLint compliant (other than using in instead of hasOwnProperty but =
that's stylistic, not an actual error), the service worker only listens for=
 the push event.

But the endpoint isn't even being created on chrome for android for me to t=
est the push on that platform.

There must be something chrome is looking for that isn't in the specificati=
on, and I can not figure out what it is.

Chrome's documentation on service workers and push API is useless to me as =
it assumes the chrome developer tools are being used, so I followed the moz=
illa documentation. But something extra (beyond a manifest.json) is clearly=
 needed for chrome and I can't figure out what it is.

Thank you for any assistance.
0
Alice
11/18/2016 4:12:38 PM
comp.lang.javascript 38370 articles. 0 followers. javascript4 (1315) is leader. Post Follow

2 Replies
323 Views

Similar Articles

[PageSpeed] 35

First hit on Google: -
https://developers.google.com/web/updates/2015/03/push-notifications-on-the-open-web

you have to register with Google.

Please, PLEASE, *PLEASE* tell anyone and everyone that you need a 
broadcast API as support by GOOGLE Microsoft, and Apple for native apps!


0
Richard
11/19/2016 2:53:23 AM
Alice Wonder wrote:
^^^^^^^^^^^^
Is that your real name?

> […]
> I don't have access to Chrome for Desktop, Google doesn't support Chrome
> on CentOS 7 which is my desktop.

No, that is your Linux distribution.  (Your desktop is probably GNOME.)

,-<https://www.centos.org/about/>
| 
| The CentOS Linux distribution is a stable, predictable, manageable and 
| reproducible platform derived from the sources of Red Hat Enterprise
| Linux (RHEL).

So you can certainly install Chrome there, however I would suggest Chromium 
instead.
 
> But Chrome on Android, the subscribe button is shown and activated
> indicating Chrome on Andoid supports what is needed - but it doesn't work.

Chrome on Android is a different environment than Chrome on the desktop, the 
same as Firefox on Android is different from Firefox on the desktop.
 
> Does anybody know what is going on? What chrome wants?

<http://catb.org/esr/faqs/smart-questions.html>
 
> The service worker and JavaScript the pages use to install the service
> worker are JSLint compliant (other than using in instead of hasOwnProperty
> but that's stylistic, not an actual error),

Use JSHint & friends instead.

> the service worker only listens for the push event.
> 
> But the endpoint isn't even being created on chrome for android for me to
> test the push on that platform. […]

  “Talk is cheap.  Show me the code.”
    —Linus Torvalds
 
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
0
Thomas
11/25/2016 10:18:15 PM
Reply: