Skip to content

Background Geolocation / Geofencing + postMessage demo #496

@FluorescentHallucinogen

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions