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,
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.
There's a lot of misinformation being spread about mobile apps.
- 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.
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.
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.
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:
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With