Webview 'onMessage` is not working in Android.

  1. SDK Version: 38
  2. 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}

        />

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.