Skip to content

Problem with WebView component and postMessage #20069

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
timboektoe opened this issue Jul 6, 2018 · 1 comment
Closed

Problem with WebView component and postMessage #20069

timboektoe opened this issue Jul 6, 2018 · 1 comment
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@timboektoe
Copy link

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

@react-native-bot
Copy link
Collaborator

We are automatically closing this issue because it does not appear to follow any of the provided issue templates.

Please make use of the bug report template to let us know about a reproducible bug or regression in the core React Native library.

If you'd like to start a discussion, check out https://discuss.reactjs.org or follow the discussion template.

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. 📋No Template labels Jul 6, 2018
@facebook facebook locked as resolved and limited conversation to collaborators Jul 18, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 18, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

2 participants