![](https://img.haomeiwen.com/i12446869/b053abe6848f9e49.png)
解决办法
injectedJavascript should instead be the following
(function(){
var originalPostMessage = window.postMessage;
var patchedPostMessage = function(message,targetOrigin,transfer){
originalPostMessage(message,targetOrigin,transfer);
};
patchedPostMessage.toString = function(){
return String(Object.hasOwnProperty).replace('hasOwnProperty','postMessage');
};
window.postMessage = patchedPostMessage;
})();
And then it works! 😄
And if any one is interested, in my code instead of writing a giant string I did the following\
=
=
=
=
=
>>>>>>>>>>>>>⬇️
const patchPostMessageFunction = function(){
var originalPostMessage = window.postMessage;
var 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)+ ')();';
...
<WebView injectedJavaScript={patchPostMessageJsCode} />
网友评论