GithubHelp home page GithubHelp logo

Comments (7)

ianhowe76 avatar ianhowe76 commented on July 2, 2024 1

I implemented a fix that seems to work ok

Instead of calling injectDeferredObject in the injectScriptCode branch (here: https://github.com/apache/cordova-plugin-inappbrowser/blob/master/src/android/InAppBrowser.java#L254)

I instead call my new function runJavascriptWithResult(args.getString(0), callbackContext)

The implementation of this function is

private void runJavascriptWithResult(String scriptToInject, CallbackContext callbackContext) {
        final String finalScriptToInject = scriptToInject;
        final CallbackContext finalCallbackContext = callbackContext;
        final String callbackId = callbackContext.getCallbackId();
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @SuppressLint("NewApi")
            @Override
            public void run() {
                inAppWebView.evaluateJavascript(finalScriptToInject, new ValueCallback<String>() {
                    @Override
                    public void onReceiveValue(String s) {
                    	PluginResult pluginResult;
                    	try {
                          pluginResult = new PluginResult(PluginResult.Status.OK, new JSONArray("[" + s + "]"));
                        } catch(JSONException e) {
                            pluginResult = new PluginResult(PluginResult.Status.JSON_EXCEPTION, e.getMessage());
                        }
                        finalCallbackContext.sendPluginResult(pluginResult);
                    }
                });
            }
        });
    }

Would this be a suitable fix? If so I can create a PR

from cordova-plugin-inappbrowser.

janpio avatar janpio commented on July 2, 2024

Did I understand correctly that this probably does not apply only for this plugin but all cordova-android communication?

from cordova-plugin-inappbrowser.

ianhowe76 avatar ianhowe76 commented on July 2, 2024

Anyone using prompt interface for the javascript-Java communication is affected by this Chrome update
As this plugin uses prompt for communication it affects this plugin
Is prompt interface used elsewhere within Cordova?

from cordova-plugin-inappbrowser.

janpio avatar janpio commented on July 2, 2024

I don't know - I was hoping you knew ;)

from cordova-plugin-inappbrowser.

prbehera8 avatar prbehera8 commented on July 2, 2024

Hi ianhowe76, Is the fix also works for Chrome latest version 71.

from cordova-plugin-inappbrowser.

ianhowe76 avatar ianhowe76 commented on July 2, 2024

I have only tested personally on 70.0.3538.80, however, the app that is using this patch hasn't had any customer complaints since
I am planning on creating a PR for this soon

from cordova-plugin-inappbrowser.

ianhowe76 avatar ianhowe76 commented on July 2, 2024

PR to fix this is #395

from cordova-plugin-inappbrowser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.