Skip to content

Instantly share code, notes, and snippets.

@mauriciord
Created July 16, 2018 13:05
Show Gist options
  • Save mauriciord/eac39f3176b0a03e84770141dba594e5 to your computer and use it in GitHub Desktop.
Save mauriciord/eac39f3176b0a03e84770141dba594e5 to your computer and use it in GitHub Desktop.
window.postMessage on React Native Webview - bug fix
const patchPostMessageFunction = function () {
const originalPostMessage = window.postMessage;
const patchedPostMessage = function (message, targetOrigin, transfer) {
originalPostMessage(message, targetOrigin, transfer);
};
patchedPostMessage.toString = function () {
return String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage');
};
window.postMessage = patchedPostMessage;
};
const patchPostMessageJsCode = `(${String(patchPostMessageFunction)})();`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment