-
Notifications
You must be signed in to change notification settings - Fork 936
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
how to send message from javacript to flutter? #309
Comments
it is not work !js code:
flutter code:
|
It's hard to read your comment, please format it with code tags. You can inject this on initState(); or add it straight to your local html file. Don't forget to call the method on JavascriptInterface within this method.
|
@erdemyerebasmaz thanks .I have formated my code. |
@erdemyerebasmaz I want to received message by flutter. |
You need to fork and make changes on the plugin. I've added a javascript interface and passed the listened value to a stream that can be listened inside flutter. Adjust and rename the methods according to your needs. |
I used your branch,and alse add |
Okay, if you are using my branch without any changes just add this to your initState();
Try hiding instead of closing the flutterWebviewPlugin.
|
@erdemyerebasmaz Thanks! I will try your suggestion. |
@erdemyerebasmaz Tell you good news,I have resolved this problem through your help! Thank you very much! |
@littlesalt ios How to solve |
@erdemyerebasmaz Hey, thanks a lot for this. I have a button on the page that I am loading. I am calling an onClick() event that does this:
I added this to my initState():
|
Where is webView.addJavascriptInterface and WebAppInterface? |
How listen Javascript function from backend to flutter |
As it says, the browser object model named MobileApp is not defined. See here. Try using window instead.
|
@erdemyerebasmaz Thanks for getting back to me. Earlier I was using webview_flutter but it doesn't open webviews so I am trying to switch back to this. webview_flutter provides javascript channels property and that's how I used to listen to postMessages.
But now, I don't know how to listen to these messages with flutter_webview_plugin or atleast avoid the error that says |
I solved this problem in iOS and Android, I hope it's helpful。#457 |
Can You guys provide complete flutter and js code for better understanding... |
I want to send message from js to flutter .I try using wondow.postMessage to send message to flutter,but it fail.
The text was updated successfully, but these errors were encountered: