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

setWebChromeClient is not working, and it is suspected that the settings are being overwritten #3407

Open
John24y opened this issue Apr 23, 2024 · 0 comments

Comments

@John24y
Copy link

John24y commented Apr 23, 2024

Bug description:

setWebChromeClient is not working, and it is suspected that the settings are being overwritten.

To Reproduce:

@ReactModule(name = CustomWebViewManager.REACT_CLASS)
public class CustomWebViewManager extends RNCWebViewManager {
    /* This name must match what we're referring to in JS */
    protected static final String REACT_CLASS = "RCTCustomWebView";

    public class CustomWebChromeClient extends RNCWebChromeClient {

        public CustomWebChromeClient(RNCWebView webView) {
            super(webView);
        }

        @Override
        public void onProgressChanged(WebView webView, int newProgress) {
            super.onProgressChanged(webView, newProgress);
            Log.d("webview", "enter onProgressChanged:" + webView.getUrl());
        }
    }

    @Override
    public RNCWebViewWrapper createViewInstance(ThemedReactContext reactContext) {
        RNCWebViewWrapper wrapper = super.createViewInstance(reactContext, new RNCWebView(reactContext));
        wrapper.getWebView().setWebChromeClient(new CustomWebChromeClient(wrapper.getWebView()));
        return wrapper;
    }

    @Override
    public String getName() {
        return REACT_CLASS;
    }

}

Expected behavior:
Expect CustomWebChromeClient works, and CustomWebChromeClient#onProgressChanged being called.
But its not. After debuging the code, I found this method in RNCWebViewManagerImpl.kt is questionable.

    fun setAllowsFullscreenVideo(viewWrapper: RNCWebViewWrapper, value: Boolean) {
        val view = viewWrapper.webView
        mAllowsFullscreenVideo = value
        // ** After this code, my CustomWebChromeClient has been overwrite **
        setupWebChromeClient(view)
    }

Environment:

  • OS: windows
  • OS version: 10
  • react-native version: 0.73.6
  • react-native-webview version: 13.8.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant