Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a manifest and service worker and all that junk #1

Open
Rich-Harris opened this issue Sep 14, 2018 · 7 comments
Open

Add a manifest and service worker and all that junk #1

Rich-Harris opened this issue Sep 14, 2018 · 7 comments

Comments

@Rich-Harris
Copy link

...so that we Android users can add it to the home screen

@alizauf
Copy link
Owner

alizauf commented Sep 14, 2018

Good call. If I can't find any e-bikes, might work on adding that this weekend.

@josephfrazier
Copy link

josephfrazier commented Sep 14, 2018

Does anyone know if adding it to the home screen means that it can run in the background, so your phone could be in your pocket with the screen off, but still notify you when there's a bike nearby?

I've been working on a much less polished version of this project at https://reported-web.herokuapp.com/electricitibikes (code at https://github.com/josephfrazier/Reported-Web/blob/51f31cae45f5f554252a102a50744d36e8879c33/src/routes/electricitibikes/ElectriCitibikes.js), and getting it to work without being in the foreground was a goal of mine, but I don't know how easy that is.

EDIT: Getting the current position might also not be possible, which could pose a problem for the use case of: I'm riding a manual citibike, but would like to switch to an electric one if possible w3c/ServiceWorker#745

@Rich-Harris
Copy link
Author

Background notifications are somewhat involved — basically there needs to be a server that maintains a list of clients (service workers) and can send notifications to them, and the service worker needs to have some code like

self.addEventListener('push', event => {
  // some magic happens
});

There's a guide here — the length of it tells you how much of a nuisance it is to set up. It's definitely doable, it's just a lot more work than foreground notifications.

@josephfrazier
Copy link

Thanks for the info! That's what I was suspecting, that it couldn't be completely client-side anymore, but I was still a bit unsure. Maybe I'll get around to it someday... :P

@Rich-Harris
Copy link
Author

Unless the service worker was responsible for polling the stations you've marked, perhaps... I don't know if that's possible but it might be. Hmm, now I want to investigate 🤔

@josephfrazier
Copy link

Yeah, I'm currently using Server-sent events, but I don't know if those keep going to a backgrounded PWA.

@RichardMaher
Copy link

ServiceWorkers need to simply implement the TravelManager detailed here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants