Exploring ServiceWorkers for Discourse

(Sam Saffron) #3

I like this, but it needs to be tightly scoped.

Our first priority is getting the push notifications going for Android, cause that unlocks brand new functionality.

Our second priority is a PR to message bus that enables centralizing of message bus polling without turning message_bus.js into a “soup” of completely hard to understand and debug code that falls back super cleanly.

(Jeff Atwood) #4

And before we do any of this, there are critical items on the 1.4 release list that are not done…

(Tom Newsom) #5

Praises be for push notifications! :smiley:
I bet Safari doesn’t support them :frowning:

(Alan Tan) #6

I did a quick spike and got it to work. Do we have a :+1: to continue?

(Sam Saffron) #7

Sure go ahead :thumbsup:

(Alan Tan) #8

Finally got it to work properly :smile:

Tapatalk API implementation project
Android chrome & notifications
(Tom Newsom) #9

Oh my :smile:

Can’t wait to try this out!
(and 10 seconds later have iOS users complain that they’re not supported. Come on Apple!)

(Kane York) #10

Here’s the docs for Firefox push notifications :wink: Push API - Web APIs | MDN

(Alan Tan) #11

Hmmm the Push API isn’t available until FireFox 42, I’ll wait till it is released first before integrating push notifications for FireFox. In the mean time, I’ll update my PR to account for different browsers.

(Stefano Costa) #12

Seems like Firefox 44 has Push Notifications:


(Florian Bender) #13

This is not (or at least no longer) true, see the clients.claim() API: https://slightlyoff.github.io/ServiceWorker/spec/service_worker/#clients-claim

(Héctor Fernández) #14

Good news from Microsoft land: service workers and the push api moved to High Priority in the roadmap for Edge.

(Rob Nicholson) #15

Big thumbs up for push notifications. We’re currently trialling Discourse to replace PhpBB for CAMRA (170,000 members) and I’ve been a fan of Discourse - having used StackExchange for years.

The single biggest requirement for the replacement system is so smartphone and tablet friendly but Discourse isn’t sadly ticking all the boxes. It’s better than PhpBB but maybe not enough for us to recommend :frowning:

(Sam Saffron) #16

I think that is a bit unfair, I use Discourse quite extensively over mobile as do many others, we have spent enormous amounts of engineering effort making sure the mobile story is great. To add to that you can do everything over email (reply, like, open topics etc) which also captures a bunch of use cases.

We plan to add support for push notification in a shell mobile application. However, the current experience is far superior to many other mobile sites I have seen and use. You achieve much of the notification over email anyway.

(Rob Nicholson) #17

I’m not sure why it’s “unfair”. I like Discourse but to say it’s as mobile friendly as it could be would be ignoring the truth. The stakeholders in our project are not IT specialists and like the rest of the world, have come to rely on their mobile phone. So when they say “why doesn’t it work like this?”, we’re immediately on the back foot defending the fact that Discourse is a web application and not a native one. I’ve asked whether I can start a separate thread on, for us, will be a key decision point.

(Sam Saffron) #18

There are multiple threads on this, feel free to weigh in there



I’d keep an eye on ember-service-worker · Issue #45 · ember-cli/rfcs · GitHub and GitHub - html-next/skyrocket: Ambitious applications aren’t single threaded. as well.

(Dan Dascalescu) #20

Massive support signal from Google last week: the 2016 Founders’ Letter mentions Progressive Web Apps as one of Google’s two investments in the mobile web:

We also continue to invest in the mobile web […] Over this past year, Google has worked closely with publishers, developers, and others in the ecosystem to help make the mobile web a smoother, faster experience for users. A good example is […] Progressive Web Apps (PWA), which combine the best of the web and the best of apps—allowing companies to build mobile sites that load quickly, send push notifications, have home screen icons, and much more.

Service Worker support is the cornerstone of PWA support.

As a Developer Advocate at Google helping with PWA and AMP efforts, please let me know if there’s anything we can do to help flesh out SW support - which I do see running at https://meta.discourse.org when I use a mobile UA.

(Dean Taylor) #21

EDIT: Added another relevent video.

Recent talks from Google I/O 2016:

Service Workers - Instant Loading: Building offline-first Progressive Web Apps

A good potion of this walks through the “offline” capability.

Web Push Notifications

A walk though what push notifications should be used for, overview of systems involved and basic code patterns.
Note the recent name change from “Google Cloud Messaging” (GCM) to “Firebase Cloud Messaging” (FCM).

These videos are long, the first is 45 minutes long so - do yourself a favour and use the Video Speed Controller extension in Chrome.

(Dean Taylor) #22

Good news for Service Worker…

The Fetch API MS Blog post link: Fetch (or the undeniable limitations of XHR) - Microsoft Edge Blog