Encountering a challenge while implementing webview functionality. I am attempting to inject a JavaScript function into my webview, but it seems to only be functioning properly on iOS and not on Android.
Take a look at my code :
Webview :
<WebView
source={{uri:"http://mywebview.com/webview.php"}}
injectedJavaScript={jsCode}
mixedContentMode={'compatibility'}
javaScriptEnabledAndroid={true}
style={{height: 300}} />
Javascript Code to Inject :
let jsCode = `function doPopUp() {
document.querySelector('#myBody').style.backgroundColor = 'red';
alert('hello world from webview');
}`;
The JS injection works fine on iOS, but encounters issues on Android. However, when I directly include the JS code in the php file and open it in an Android browser, it works perfectly. Interestingly, if I remove the syntax inside the JS function, it also works fine. What could be causing this discrepancy and how can I resolve it?