It definitely is interesting -- I haven't tried it out anywhere, but there
are tests for it that at least show how to use it:

https://android.googlesource.com/platform/cts/+/764c7c7/tests/tests/webkit/src/android/webkit/cts/PostMessageTest.java

It looks like it just works with strings on the Java side (WebMessage only
has a String constructor), so de/serialization would be an issue in Cordova
code, but it should be fast on the WebView side. I've no idea what kind of
latency could be expected.

On Wed, Jan 27, 2016 at 9:23 AM, Homer, Tony <tony.ho...@intel.com> wrote:

> Pretty exciting! Definitely seems like it would be cleaner.
> Do you think this would be a new bridge mode?
>
> I spent a couple minutes trying to find an example of how to use this, but
> didn't come up with anything outside of the docs.
>
> Looks like the relevant classes are WebMessage, WebMessagePort and WebView.
> The relevant methods on WebView are createWebMessageChannel[1] and
> postWebMessage[2].
> createWebMessageChannel returns an array of 2 WebMessagePorts.
> I don't quite get how it works - how does the JS side know what port to
> use?
> The WebMessagePort overview [3] talks about transferring a port to JS -
> what does that mean?
>
> I'll come back to this later and re-read the docs.
> Thanks for bringing this up, Joe!
>
>
> [1]
> http://developer.android.com/reference/android/webkit/WebView.html#createWebMessageChannel()
> [2]
> http://developer.android.com/reference/android/webkit/WebView.html#postWebMessage(android.webkit.WebMessage,
> android.net.Uri)
> [3]
> http://developer.android.com/reference/android/webkit/WebMessagePort.html
>
>
> On 1/27/16, 1:10 AM, "Joe Bowser" <bows...@gmail.com> wrote:
>
> >http://developer.android.com/reference/android/webkit/WebMessage.html
> >
> >I'm curious as to how this works in comparison to our current method of
> >passing something back from native to the browser and whether this would
> be
> >faster/cleaner.  This would be Android WebView specific, and only would
> >work on API Level 23, but it's interesting.
> >
> >Thoughts?
>

Reply via email to