Skip to content
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

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

Closed
iies opened this issue Apr 2, 2013 · 5 comments
Closed

Comments

@iies
Copy link

iies commented Apr 2, 2013

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.

@splhack
Copy link
Contributor

splhack commented Apr 2, 2013

Thank you for sharing the information with us!

@iies iies closed this as completed Apr 2, 2013
@iies iies reopened this Apr 2, 2013
@privman
Copy link

privman commented Oct 31, 2013

This appears to be caused by change in addJavascriptInterface between Android 4.1 (JELLY_BEAN) and 4.2 (JELLY_BEAN_MR1).
Starting from 4.2, only public functions which are annotated with "JavascriptInterface" are accessible from JS, see http://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface(java.lang.Object, java.lang.String)
Adding "import android.webkit.JavascriptInterface;" at the top of WebViewPlugin.java and "@JavascriptInterface" immediately before the definition of WebViewPluginInterface.call()
I'll to get around to making a proper pull request with the fix next week (if I don't forget :) )

splhack added a commit that referenced this issue Dec 30, 2013
@thanh06
Copy link

thanh06 commented Apr 9, 2015

@splhack you can upload WebViewPlugin.jar fix version for me?
Thanks you

@nhiepphong
Copy link

I can't scroll and touch the website in Android.
It's ok in iOS.

@KojiNakamaru
Copy link
Member

The latest version (https://github.com/gree/unity-webview/tree/39d08af311278693abb8c57129dc1b434b062c25) should have no problem. Please try the latest sample/ and dist/unity-webview.unitypackage.

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

No branches or pull requests

6 participants