Open xpbtmusic opened 6 years ago
Hi @xpbtmusic
If you need just sent a data when your html file load, you could use the prop injectedJavaScript
instead.
Something like:
return (
<WebViewAndroid
ref="webViewAndroidSample"
javaScriptEnabled={true}
injectedJavaScript={`window.myMessageToRecover = 'Hello from React Native';`}
url={"https://yourwebsite.com"}
style={{ flex: 1 }} />
);
And then, in your HTML you could recover the variable window.myMessageToRecover
in on page ready or in your page load events.
How do I receive a message sent by a webview in an html file when I load html? The official webview is using
document.addEventListener('message', function (e) {}