feat(Android/iOS postMessage): refactoring the old postMessage implementation (#303)
fixes #29
fixes #272
fixes #221
fixes #105
fixes #66
BREAKING CHANGE: Communication from webview to react-native has been completely rewritten. React-native-webview will not use or override window.postMessage anymore. Reasons behind these changes can be found throughout so many issues that it made sense to go that way.
Instead of using window.postMessage(data, *), please now use window.ReactNativeWebView.postMessage(data).
Side note: if you wish to keep compatibility with the old version when you upgrade, you can use the injectedJavascript prop to do that:
const injectedJavascript = `(function() {
window.postMessage = function(data) {
window.ReactNativeWebView.postMessage(data);
};
})()`;
Huge thanks to @jordansexton and @KoenLav!