Created
July 16, 2018 13:05
-
-
Save mauriciord/eac39f3176b0a03e84770141dba594e5 to your computer and use it in GitHub Desktop.
window.postMessage on React Native Webview - bug fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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