You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
send like that: window.ReactNativeWebView.postMessage
omarcelomadeira, srilalitharanikintali, burhanshakir, tsdmrfth and ghanshyam-1805paulLee73051, CrazyOldDoctor, sohoorc, vegtelenseg, pavelaron and 23 moreasmakhalfallah2018 and aveth
@cristianomesquita thank you for the response, I have use window.ReactNativeWebView.postMessage for sending messages from webview to react native, but from the react native part i can not send messages to the webview.
this.window.addEventListener('message', ....) ----- It's worked for me right now
instead of
this.document.addEventListener('message', ....) ---- it's worked in older version for me
Good luck!
iddan, paulLee73051, Adherentman, Davorak, terfender and 7 morepaulLee73051, chauhan19911, ali-thowfeek, ilkerceng and yngfoxxchauhan19911, ali-thowfeek, ilkerceng and yngfoxx
Hi, I'm trying to send messages from the WebView to Android but onMessage isn't triggered. I can see the initial "Hi!" and the view is filled with "hi" every second to test js inside the WebView, but the console doesn't show anything. I'm using RN 0.57.7 with WV 5.2.1, also tried document as @iddan says but it doesn't work either...
You can literally replicate the undocumented postMessage functionality by following the guide above. 🤔 If you want to receive a message on the window you can inject a function that does just that.
Activity
cristianomesquita commentedon Feb 22, 2019
send like that: window.ReactNativeWebView.postMessage
peymancyb commentedon Feb 23, 2019
@cristianomesquita thank you for the response, I have use
window.ReactNativeWebView.postMessage
for sending messages from webview to react native, but from the react native part i can not send messages to the webview.paulLee73051 commentedon Feb 23, 2019
The same problem
sadvit commentedon Feb 25, 2019
I have the same issue for iOS
Call webView.postMessage don't lead to fire 'message' event inside webView
Version:
react-native-webview@5.2.0
react-native@0.58.4
sadvit commentedon Feb 25, 2019
I've got the solution
Inside webView we need to use:
this.window.addEventListener('message', ....) ----- It's worked for me right now
instead of
this.document.addEventListener('message', ....) ---- it's worked in older version for me
Good luck!
iddan commentedon Feb 25, 2019
window
works for me as well. This is a breaking change from past implementation!!!SuGod commentedon Feb 26, 2019
I have the same problem.
onMessage
cannot receive messages. Switch to the webview on react-native and it work."react-native-webview": "^5.2.1",
"react": "16.6.3",
"react-native": "0.58.4",
iddan commentedon Feb 26, 2019
For people coming here:
document
for Android,window
for iOSfauno commentedon Feb 26, 2019
Hi, I'm trying to send messages from the WebView to Android but onMessage isn't triggered. I can see the initial "Hi!" and the view is filled with "hi" every second to test js inside the WebView, but the console doesn't show anything. I'm using RN 0.57.7 with WV 5.2.1, also tried
document
as @iddan says but it doesn't work either...fauno commentedon Feb 26, 2019
nevermind, got it to work with
onMessage={event => console.log(event.nativeEvent.data)}
:)romreed commentedon Feb 28, 2019
@fauno not work for me
can you show me please full example
"react-native-webview": "^5.2.1"
"react-native": "0.58.4",
punksta commentedon Mar 4, 2019
https://github.com/react-native-community/react-native-webview/blob/master/docs/Guide.md#communicating-between-js-and-native
you can find
injectJavaScript
useful. @peymancybpeymancyb commentedon Mar 5, 2019
Thank you @punksta but what i need is postMessage feature and still this feature does not work on android devices
Titozzz commentedon Mar 5, 2019
You can literally replicate the undocumented postMessage functionality by following the guide above. 🤔 If you want to receive a message on the window you can inject a function that does just that.
27 remaining items