posting a message to webview doesnt work
See original GitHub issueHi ! I was sending a message to my WebView like this :
this.myWebView.postMessage(
JSON.stringify({
messageType: "handleServerResponse",
responseData: json,
requestId
})
);
but after the upgrade it has stopped working, and now i’m trying to use the injectJavaScript
instead.
This is what i am trying to do :
const injectedJS= `
window.postMessage("${JSON.stringify({
messageType: "handleServerResponse",
responseData: json,
requestId
})}");
true;`
this.myWebView.injectJavaScript(injectedJS)
but the message is not received on the WebView side, communication from the WebView to the app it self by using window.ReactNativeWebView.postMessage(data); is working fine.
please help
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
React Native WebView postMessage does not work
I can't get React Native WebView postMessage to work. The React Native app successfully receives the post message sendt from the web app....
Read more >Window.postMessage() - Web APIs | MDN
The window.postMessage() method safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it ...
Read more >Fixing React Native WebView's postMessage for iOS
The rn-webview package works by directing window.postMessage traffic to history.pushState instead. While React Native's iOS implementation cannot handle ...
Read more >React Native WebView: A complete guide - LogRocket Blog
In this post, we are going to look at the most common use cases of React Native WebView, including: Getting started; Creating the...
Read more >WebView - React Native
mixedContentMode · never (default) - WebView will not allow a secure origin to load content from an insecure origin. · always -...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@MaxToyberman
https://stackoverflow.com/questions/41160221/react-native-webview-postmessage-does-not-work#
i used
is worked.
ok, i have found a solution but i am not sure this is the best way.