Skip to content

Resolution of Uncaught TypeError: Object [object Object] has no method 'call' #10

@iies

Description

@iies

Thank you for great library for Unity 3D. But I found one bug that native code can't catch callback from javascript. This problem appears only over Android 4.2.

So I have found on google. This is hint I found : http://stackoverflow.com/questions/14031635/android-4-2-1-webview-and-javascript-interface-breaks

I changed build target to 4.2.2 and modified code like below. (just @JavascriptInterface added)

class WebViewPluginInterface
{
    private String mGameObject;

    public WebViewPluginInterface(final String gameObject)
    {
        mGameObject = gameObject;
    }

    @JavascriptInterface
    public void call(String message)
    {
        UnityPlayer.UnitySendMessage(mGameObject, "CallFromJS", message);
    }
}

In result, this is work fine after added an annotation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions