Skip to content

Add support for sending data from webview to native in iOS and Android#457

Closed
OPY-bbt wants to merge 3 commits into
fluttercommunity:masterfrom
OPY-bbt:message
Closed

Add support for sending data from webview to native in iOS and Android#457
OPY-bbt wants to merge 3 commits into
fluttercommunity:masterfrom
OPY-bbt:message

Conversation

@OPY-bbt

@OPY-bbt OPY-bbt commented Jun 26, 2019

Copy link
Copy Markdown
  • create the local http-server in example/html folder (for example: by http-server)
  • modify the messageUrl in main.dart to your http-server url
  • run the example project and click the Open Webview (message demo)button
  • click send to flutter button in webview and you can see the result in the bottom.

public void postMessage(String value){
Map<String, String> postMessageMap = new HashMap<>();
postMessageMap.put("postMessage", value);
FlutterWebviewPlugin.channel.invokeMethod("onPostMessage", postMessageMap);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a error:
java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: JavaBridge
maybe use 'new Handler(Looper.getMainLooper())'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you solve this error
?
I have a error:
java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: JavaBridge
maybe use 'new Handler(Looper.getMainLooper())'
I am getting the same

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add mainLooper in commit, are you sure on the lastest branch?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#523 is already implemented on the main branch

@ashbin

ashbin commented Jul 18, 2019

Copy link
Copy Markdown

#71

@diegovar

Copy link
Copy Markdown

Can this be merged in?

@kevinpthorne

Copy link
Copy Markdown

Please? x)

@rinlv

rinlv commented Aug 16, 2019

Copy link
Copy Markdown
Contributor

still waiting 🔢

@rinlv

rinlv commented Aug 19, 2019

Copy link
Copy Markdown
Contributor

I solved this problem with dynamic channel name for Android and iOS #523. Hope it's helpful

@ragaisis

Copy link
Copy Markdown

This one is is important for us too

@phamquan

phamquan commented Oct 8, 2019

Copy link
Copy Markdown

Please resolve and merge this request

1 similar comment
@hungbu

hungbu commented Oct 16, 2019

Copy link
Copy Markdown

Please resolve and merge this request

@OPY-bbt

OPY-bbt commented Oct 17, 2019

Copy link
Copy Markdown
Author

This is already implemented on the main branch, see example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants