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
Hello. My use case is multiple WebViews per screen, and each posting messages (separately) to track their content height.
Turns out:
window.ReactNativeWebView.postMessage (inside iframe) fails, whereas this is the correct way for Android/iOS
using window.postMessage (inside iframe) with onMessage={listen} won't propagate
using window.parent.postMessage (inside iframe) with onMessage={listen} works, BUT you can't tell between instancess (unless you pass some guid back and forth)
I managed to make postMessage calls in react-native-autoheight-webview work thanks to advice from this comment: #55. But, as noted, window.parent.postMessage equally affects all WebViews, so they get set the same height, which is incorrect.
I'm now working towards passing a guid for identification, but it would be nice if react-native-web-webview just worked out of the box. I tried replacing window.addEventListener with this.frameRef.contentWindow.addEventListener as suggested, but that didn't work for me.
Could someone please make a Pull Request with a fix?
Hello. My use case is multiple WebViews per screen, and each posting messages (separately) to track their content height.
Turns out:
window.ReactNativeWebView.postMessage
(inside iframe) fails, whereas this is the correct way for Android/iOSwindow.postMessage
(inside iframe) withonMessage={listen}
won't propagatewindow.parent.postMessage
(inside iframe) withonMessage={listen}
works, BUT you can't tell between instancess (unless you pass some guid back and forth)Proposal:
Instead of
window.addEventListener('message', this.onMessage, true);
usethis.frameRef.contentWindow.addEventListener('message', this.onMessage, true);
(see this topic https://stackoverflow.com/questions/10338344/html5-setting-onmessage-handler-for-iframe-in-parent-script)
Additionally, put
window.ReactNativeWebView = window
or something similar.The text was updated successfully, but these errors were encountered: