Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

WebView postMessage do not work on iOS #12411

Closed
magicismight opened this issue Feb 16, 2017 · 3 comments
Closed

WebView postMessage do not work on iOS #12411

magicismight opened this issue Feb 16, 2017 · 3 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@magicismight
Copy link
Contributor

postMessage to WebView can not work on iOS.

First, postMessage on react-native

this.refs.webview.postMessage("any thing");

Then receive the message on WebView side, the event is always {"isTrusted": false}

  document.addEventListener('message', function (e) {
   // e.data !== 'any thing'
   // e == {isTrusted: false}
  })

Additional Information

  • React Native version: 0.41.0
  • Platform: iOS
  • Operating System: MacOS
@rgoldiez
Copy link

@magicismight - How did you resolve this? I'm seeing the same thing {"isTrusted":false}

@magicismight
Copy link
Contributor Author

@rgoldiez Everything goes fine.
You can not print the event object directly.

  document.addEventListener('message', function (e) {
    console.log(e); // This will print {isTrusted: false}
    console.log(e.data); // This will work.
  })

@rgoldiez
Copy link

rgoldiez commented Mar 1, 2017

Thank you @magicismight !!

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants