-
Notifications
You must be signed in to change notification settings - Fork 300
Background Geolocation / Geofencing + postMessage demo #496
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
Comments
And the main question: is it possible at all to receive |
@PEConn @b1tr0t @beverloo @SayedElabady @andreban Tested receiving the self.addEventListener('message', (event) => {
console.log('event', event);
});
self.onmessage = (event) => {
console.log('event', event);
}; Unfortunately, it doesn't work. This makes my whole idea of "polyfilling" Background Geolocation / Geofencing impossible. :( Any plans to add support for sending events to service worker (not only to |
Hi @FluorescentHallucinogen, thanks for testing and adding additional information! |
I've opened https://issues.chromium.org/issues/410533048. |
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.
The text was updated successfully, but these errors were encountered: