-
Notifications
You must be signed in to change notification settings - Fork 46
-
Notifications
You must be signed in to change notification settings - Fork 46
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
(andorid) geckoview use browser.runtime.connectNative("browser") is work when launch app, but it is not work when click to use port.postMessage(port undefine) #136
Comments
Any good suggestions? and the error log when invoke postMessage method :
but i do port like this in api.js :
|
it looks like you are not able to access |
I also helped with this sample web extension app, it could help you to see a full example and maybe spot a possible issue |
@xiaotianguys how are you loading |
3Q for you response @agi90 yes, i do like this:
MainActivity.java Code
|
3Q for you response @Amejia481 ; |
https://github.com/ankitrawat46/GeckoJavascript is work fine in my demo
what can i do for use port.postMessage() in other js file @Amejia481 |
@xiaotianguys ok I see the problem, you can only use extensions APIs like
|
I agree with @agi90. Something that can help to have a complete picture of what is happening is to use Remote debugging. It gives you access to all the dev tool that Firefox has, this way you can debug the website and the extension code end to end. To activate it you just have to use |
I do't understand what's different |
@Amejia481 use firefox debug as picture: |
error code :// Establish connection with app |
No offense; @Amejia481 you sure is work fine ? https://github.com/ankitrawat46/GeckoJavascript ; I am clone and run project , app crash; |
No problem :) |
@Amejia481 how's the progress , Any information update ? |
@xiaotianguys sorry for the delay, the initial example was based on an old version of geckoview which API was deprecated. I cloned and updated the previous example using the new extension api. Hope it helps. I added two version:
In version 1 you can see the extension interacting with the site web content as is changing the background of some items on Wikipedia :) |
3Q @Amejia481 ; #136 (comment) is same as official document description ;My problem is that it is stuck when use port.postMessage in js function, not demo can't work ;(like i said before my demo is work fine) so i can not send message when invoke button by myself |
As @agi90 mentioned on #136 (comment), this API do not exists on a normal website context, to use the web extension APIs you need to be in web extension context. For this reason, he suggested to load the page using the web extension context: Extension context -> VS Website context -> Another alternative is to set an options_ui in the manifest that can be accessed via ext.metaData!!.optionsPageUrl!! |
it's a pity that can not work too; @Amejia481 can you show me a demo?(about use port.postMessage send message when invoke button by ourself) looking forward to your update |
#136 (comment) it is work fine , and i have done ; but i do't know how to use port.postMessage , as like click the Button and send message @Amejia481 |
To help you better could you tell us which is the end goal or use case that you are trying to achieve? This way we can steer you up through all the possible options. If you prefer you can also could chat with the whole team using Matrix: gv-webext:mozilla.org chat room (How to connect), this way you can have a more diverse opinions. |
Is everybody struggling with the same thing ? Could you, please, check issue #163 |
不要把它放OnCreate里!
|
test.html
api.js
Result Log:
Reference :
The text was updated successfully, but these errors were encountered: