Using window.ReactNativeWebView on Android KitKat returns an empty object
See original GitHub issueBug description:
I’m developing an app that consists of a webview and a few extra features based on postMessage
/onMessage
and injectJavascript
. In order to be able to use the app, the webview should support these methods across all android versions. I’ve tried these methods on an emulator and a real device and when using the app in Android 4.4 window.ReactNativeWebView
is an empty object: {}
instead of an object with postMessage. That works for all versions greater than 4.4.
I’ve also tried disabling proguard without success thinking that could be the problem as the window.ReactNativeWebView
is based on the use of @JavascriptInterface
annotation. I found it happens in debug and release variants indistinctly.
Expected behavior:
I’m expecting window.ReactNativeWebView
to behave the same way across all the android versions so the web can send data with postMessage
and the app can receive that data.
Environment:
- OS: Android
- OS version: 4.4.2
- react-native version: 0.61.5
- react-native-webview version: 8.1.2
- minSdkVersion = 18
- compileSdkVersion = 28
- targetSdkVersion = 28
Repository with repro: https://github.com/mikelros/ReactNativeWebViewKitKat Screenshots of that repository:
Android 4.4.2
Android 5.1
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7
Top GitHub Comments
NVM, it’s working only for android 5.0 and above
@bulby97 nope. Still not supporting Android 4.x versions.