The webpage rendered inside webview only receives {isTrusted: true}
when receiving events.
This issue can be reproduced by adding the following code to the webage that attaches a function to the message
event:
window.addEventListener('message', this.handleMessage);
In the webview, I activate the message event using the injectJavaScript
method like this this.webview.injectJavaScript(
window.postMessage(${stringMessage}, ‘*’); true;)
where stringMessage is as JSON.stringified
object
Expected behavior:
I expected the entire stringified object to be received as a variable in the handleMessage
function. Instead, I only receive the {isTrusted: true}
Environment:
- OS: Windows, Android OnePlus 5
- OS version: 10
- react-native version: 0.59.8 using Expo https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz
- react-native-webview version: 5.12.0
@reggie3 … Humor me and trying changing
this.addDebugMessage({event})
tothis.addDebugMessage(event.data)