Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Libraries/Components/WebView/WebView.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ class WebView extends React.Component {
*/
onNavigationStateChange: PropTypes.func,
/**
* A function that is invoked when the webview calls `window.postMessage`.
* Setting this property will inject a `postMessage` global into your
* A function that is invoked when the webview calls `window.postMessageNative`.
* Setting this property will inject a `postMessageNative` global into your
* webview, but will still call pre-existing values of `postMessage`.
*
* `window.postMessage` accepts one argument, `data`, which will be
* `window.postMessageNative` accepts one argument, `data`, which will be
* available on the event object, `event.nativeEvent.data`. `data`
* must be a string.
*/
Expand Down
3 changes: 1 addition & 2 deletions React/Views/RCTWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ - (void)webViewDidFinishLoad:(UIWebView *)webView
}
#endif
NSString *source = [NSString stringWithFormat:
@"window.originalPostMessage = window.postMessage;"
"window.postMessage = function(data) {"
@"window.postMessageNative = function(data) {"
"window.location = '%@://%@?' + encodeURIComponent(String(data));"
"};", RCTJSNavigationScheme, RCTJSPostMessageHost
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,7 @@ public void onReceiveValue(String value) {
}

loadUrl("javascript:(" +
"window.originalPostMessage = window.postMessage," +
"window.postMessage = function(data) {" +
"window.postMessageNative = function(data) {" +
BRIDGE_NAME + ".postMessage(String(data));" +
"}" +
")");
Expand Down