Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to track geolocation with a service worker while PWA is not open

Is it possible to read from local storage and track geolocation in PWAs with a service worker while app is not open on phone (in background)

So far my research is pointing to no, and I am finding that the PWA needs to be open for location services.

Thank you,

like image 914
Blue Space Avatar asked Jan 15 '19 23:01

Blue Space


People also ask

Can PWA use geolocation?

PWA geolocation allows you to not only keep track of up-to-date geographical information but also perform turn-by-turn navigation to guide users to a specific location or display points of interest that are within their reach. This function can be used to indicate a route. It is useful for geotagging custom content.

Can Web apps use GPS?

There's a lot of misinformation being spread about mobile apps.

How do I find the GPS location in my browser?

- You may be able to use to Google Latitude API: code.google.com/apis/latitude - With this it is possible to get the client's current location: code.google.com/apis/latitude/v1/… For future readers, the accuracy is measured in meters.

Why do I need to enable location tracking for my PWA?

After you create a PWA solution, you need to enable it to get location so that users’ demographics can be researched to offer more personalized services. To avoid confidentiality issues, user data access approval is requested, which works only when the PWA page is open.

What is the use of geolocation in PWA?

PWA geolocation allows you to not only keep track of up-to-date geographical information but also perform turn-by-turn navigation to guide users to a specific location or display points of interest that are within their reach. This function can be used to indicate a route. It is useful for geotagging custom content.

How to detect the user’s location in a PWA?

Suppose that the user is on a supported browser, you can get your PWA to easily detect the user’s location by using the Geolocation API, or to be more specific, by using the navigator.geolocation object within it. Here’s how you do it right in your PWA:

How to stop the watchposition location update in PWA?

Here, we need a method to periodically obtain the watchPosition location. The method returns a unique transaction ID that can be used to stop receiving location updates. By using the unique identifier and navigator.geolocation.clearWatch method, you can stop tracking the position. Most PWA apps don’t use background geolocation.


1 Answers

The solution is at hand and has been for some years now as this POC clearly testifies. Unfortunately W3C and lobbyists such as Jake Archibald have fought tooth and nail to prevent it from being made available :-(

Why? I know not. The "cui bono" argument points to plug-in vendors such as Ionic whose whole raison d'etre appears to be background geolocation.

See this link for complete story.

like image 180
McMurphy Avatar answered Sep 17 '22 14:09

McMurphy