Skip to content

Commit

Permalink
WebView: onMessage should not break postMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmod committed Mar 24, 2018
1 parent 1acef45 commit ba02b9b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions React/Views/RCTWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView
"}"

"window.postMessage = function(data) {"
"window.originalPostMessage.apply(window, arguments);"
"messageQueue.push(String(data));"
"processQueue();"
"};"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ public void onReceiveValue(String value) {
loadUrl("javascript:(" +
"window.originalPostMessage = window.postMessage," +
"window.postMessage = function(data) {" +
"window.originalPostMessage.apply(window, arguments);" +
BRIDGE_NAME + ".postMessage(String(data));" +
"}" +
")");
Expand Down

0 comments on commit ba02b9b

Please sign in to comment.