Search code examples
androidcordovainappbrowser

sendJavascript doesn't works in InAppBrowser (migration from Cordova 2.7 to 3.6.4)


When I finished the migration, CordovaActivity.sendJavascript was marked as deprecated.

I call this method from an InAppBrowser Cordova Plugin and with 2.7 works but in Cordova 3.6.4 don't.

Console shows:

Set native->JS mode to null

How should i call sendJavascript in Cordova 3.6.4? What is the replacement for this deprecated method?

Thanks


Solution

  • First of all, you shouldn't use cordova plugins inside InAppBrowser, InAppBroser should be used just to display external websites without leaving your app

    Anyway, you can execute javascript from the native part using this:

    String js = "alert('test')";
    yourInAppBrowserWebView.loadUrlNow("javascript:" + js);