- SDK Version: 38
- Platforms(Android/iOS/web/all): android
I have a site connected with Webview. I need to get some information from this site. I sent this by mail. It worked on iOS but not Android. Here is my sample code
web
let sendMessageToNative = () =>{
let url = window.location.href
window.ReactNativeWebView && window.ReactNativeWebView.postMessage(url, '*')
}
sendMessageToNative()
react native
<WebView
allowsBackForwardNavigationGestures={true}
originWhitelist={['*']}
source={{ uri: 'x.com' }}
startInLoadingState={true}
javaScriptEnabledAndroid={true}
javaScriptEnabled={true}
onMessage={event => {
console.log("eee", event.nativeEvent.data)
alert('MESSAGE >>>>' + event.nativeEvent.data)
}}
ref={webviewRef}
/>