Open flaviolenz opened 3 years ago
Are there any updates on this? I'm very interested in getting a fully functional communication between GeckoEngineView and an Android Activity/Fragment
There's two examples how to make this work here: https://searchfox.org/mozilla-central/source/mobile/android/examples
in this demo https://github.com/a251115100/geckoview-jsdemo You can send messages use methond (window.JSBridge.postMessage('from web html')) to the app from the web side
I made some example of such communication with pre-packaged web page: https://github.com/truefedex/GeckoViewNativeWebApp Unfortunately, I had to unpack the web page files from the assets to the internal storage.
This is a workaround, albeit an inefficient one (you need to update the contents of the folder when you update the application, the files will take up twice as much space, etc.).
But if you load files directly from assets, then you won’t be able to load the content script from the web extension and organize interaction with the native part (because content_scripts.matches does not accept strings like jar: file:/data/app/ or resource://android /assets/)
This is so poorly documented: https://firefox-source-docs.mozilla.org/mobile/android/geckoview/consumer/web-extensions.html
The closest to a decent example I got was this one: https://github.com/a251115100/geckoview-jsdemo (But it lacks the webpage code)
WebView is so simple to use JavascriptInterface.
So, can anyone provide a simple straight forward example on how to do this:
x.html (hosted somewhere in the web - not deployed as a resource in the app)
On the Android side, something like this:
I already understood that I need an Extension in the middle but it is really not clear how to get the pipes connected.
MainActivity <-> Background.js <-> Content.js <-> x.html