Hey I am working with an app that has to interface with some javascript (coffeescript) code. The code JS code looks something like this:
$(".content").on "click", ".feedback", ->
window.webkit.foo.bar.message("hello")
false
So I need to add a javascript interface to my WebView like:
webView.addJavascriptInterface(new Window(), "window");
...
class Window {
@JavascriptInterface
public Webkit webkit() {
return new Webkit();
}
class Webkit {
@JavascriptInterface
public Foo foo() {
...
I am running into two problems here, first it appears you can't add properties to the global window object. And second when I change my interface name to something else, I can't seem to figure out how to add properties rather than methods.
I can get it to work in a way like this:
webkit().foo().bar().message("hello")
Has anyone done anything like this?
Thanks!