GoogleChrome / GoogleChrome/android-browser-helper

Background Geolocation / Geofencing + postMessage demo

Open
#496 5 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
832
Forks
370
Avg merge
1d 3h
Merged PRs (30d)
6

Description

As you may know, background geolocation doesn't work on the web.

The problem is that the Web Geolocation API immediately stops working as soon as the page goes from foreground to background (the tab is closed / not focused or browser / installed PWA minimized or closed).

Moreover, Geolocation API isn't available in Service Workers.

Without background geolocation, a whole bunch of apps simply can't be implemented as PWAs! :(

Is it possible to implement background geolocation natively and use `postMessage` (https://developer.chrome.com/docs/android/post-message-twa) to pass coordinates data from Android native code to JavaScript (the page code or service worker)?

I've tried to combine the https://github.com/GoogleChrome/android-browser-helper/tree/main/demos/twa-post-message demo with official demos from Android docs:

* https://github.com/android/platform-samples/tree/main/samples/location/src/main/java/com/example/platform/location/bglocationaccess
* https://github.com/android/platform-samples/tree/main/samples/location/src/main/java/com/example/platform/location/geofencing

but, unfortunately, so far without success. :(

I'm not an Android developer. The problem is that `postMessage` demo is written in Java, but official demos from Android docs are written in Kotlin.

What about creating a demo for Background Geolocation / Geofencing + `postMessage`?

The result demo could be published in the https://github.com/GoogleChrome/android-browser-helper/tree/main/demos/
as a very useful sample of "hybrid" TWA app that would help the whole community a lot!

Ideally, this should be a plug-in (module/extension) for Bubblewrap (https://github.com/GoogleChromeLabs/bubblewrap) that can be enabled/disabled in options like other features in Bubblewrap.

BTW, Bubblewrap is written in Java, not Kotlin.

Maybe it's possible to combine them into one demo without rewriting them into one language? Although all 3 demos are small.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.