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 support for web location tracking #31

Open
antonioberetini opened this issue Jul 14, 2021 · 10 comments
Open

Add support for web location tracking #31

antonioberetini opened this issue Jul 14, 2021 · 10 comments

Comments

@antonioberetini
Copy link

Is your feature request related to a problem? Please describe.
There is no reason why this plugin is not supporting browser location tracking via service worker as well

Describe the solution you'd like
If a user is using capacitor app in a browser, user should be able to give permission to track location to the application. If permission is granted, service worker continues collecting locations in the background.

Describe alternatives you've considered
This is a standard so no need for alternatives

Additional context
iOS Safari supports this only while app is used. Soon it may add support for service worker background updates too.

@diachedelic
Copy link
Collaborator

Interesting! Can you point to me to any implementations which use this approach?

@antonioberetini
Copy link
Author

antonioberetini commented Jul 15, 2021 via email

@diachedelic
Copy link
Collaborator

The example you posted does not appear to use the Geolocation API from a service worker. May I ask you where you heard this is possible? Background geolocation in the browser is a huge point of contention, which I would not expect to be quietly resolved.

@antonioberetini
Copy link
Author

antonioberetini commented Jul 16, 2021 via email

@diachedelic
Copy link
Collaborator

Oh I see, that's useful. Could you please link me to the documentation for that browser feature?

@antonioberetini
Copy link
Author

antonioberetini commented Jul 16, 2021 via email

@diachedelic diachedelic reopened this Jul 17, 2021
@ecofriend
Copy link

this feature would be helpful for prototyping and troubleshooting as well as I'm not sure where the console.log in the example prints out to.

@HarelM
Copy link
Contributor

HarelM commented Aug 16, 2022

I'm not sure this is possible yet unfortunately, I've been waiting for this for a long time...
See here:
w3c/geolocation#13
w3c/geolocation#74
w3c/geolocation-sensor#44

Having said that, we could implement a web API that follows the plugin's API and allow "regular" location with the same API of this plugin (using navigator under the hood).
In time and as the browsers implement (hopefully) the relevant required behavior we could implement the needed features so that users of this plugin won't need to change their code.

This is just a thought. Feel free to correct me or suggest otherwise.
BTW, in theory, if the webview implements this, there might not be an actual need for this plugin, but that's a different story.
I like the original idea behind Cordova that the main goal is not to exist in the end since browsers should simply implement the relevant native APIs :-)

@diachedelic
Copy link
Collaborator

It might be worth testing to see if any browser/device combination actually does support geolocation in the background using navigator.geolocation. If it turns out to be possible, I would consider adding web support to the plugin. But I am yet to hear a persuasive use case for adding foreground-only web support to this plugin.

@HarelM
Copy link
Contributor

HarelM commented Aug 17, 2022

Besides the background ability, there's the consistent API requirement, from my point of view.
The following is my code to get location in my app which is running as a web site and as a capacitor app:
https://github.com/IsraelHikingMap/Site/blob/034010910e30ea97315c809a4ca63ecf733179d0/IsraelHiking.Web/src/application/services/geo-location.service.ts
This code is littered with if capacitor statements which will be redundant in case this plugin would also support the web platform.
In theory this plugin can implement the navigator w3c spec and thus aligning the implementation with web standards, but that's a whole different story. :-)

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