Problem with WebView component and postMessage #20069
Labels
Ran Commands
One of our bots successfully processed a command.
Resolution: Locked
This issue was locked by the bot.
I am trying to get WebView component working in collaboration with my client's website. However there seems to be a problem with postMessage. Any help would be greatly appreciated.
Some parts of the website use page reload as a mechanism of polling. In the WebView onLoad function I need to execute an injected script that invokes the postMessage function in order to communicate with the ReactNative app about the status of the polling.
The problem is that postMessage somehow seems to interrupt the polling mechanism and as a result the page does not work anymore. The page does not reload itself anymore after invoking postMessage. I was puzzled for a while why postMessage has this unwanted side effect.
After adding an onNavigationStateChange handler on the webview I think I have an explanation. I see that after invoking postMessage the onNavigationStateChange handler is triggered. The url in the corresponding event object has a url prop with the following value:
react-js-navigation://postMessage?%7B%22msg%22%3A%22test%22%7D
Probably the polling mechanism of the site in my webview is interrupted by this navigation change event caused by postMessage.
Could anyone tell me whether my assumption is correct and if so, is there a way to circumvent this problem without changing the code in the site that is opened in the webview?
Thanks in advance!
Tim
The text was updated successfully, but these errors were encountered: