{"action":"created","issue":{"url":"https://api.github.com/repos/react-native-community/react-native-webview/issues/66","repository_url":"https://api.github.com/repos/react-native-community/react-native-webview","labels_url":"https://api.github.com/repos/react-native-community/react-native-webview/issues/66/labels{/name}","comments_url":"https://api.github.com/repos/react-native-community/react-native-webview/issues/66/comments","events_url":"https://api.github.com/repos/react-native-community/react-native-webview/issues/66/events","html_url":"https://github.com/react-native-community/react-native-webview/issues/66","id":365173029,"node_id":"MDU6SXNzdWUzNjUxNzMwMjk=","number":66,"title":"[DISCUSS] Cross platform API for RN<>WebView 2-way RPC/message passing","user":{"login":"fungilation","id":3803466,"node_id":"MDQ6VXNlcjM4MDM0NjY=","avatar_url":"https://avatars3.githubusercontent.com/u/3803466?v=4","gravatar_id":"","url":"https://api.github.com/users/fungilation","html_url":"https://github.com/fungilation","followers_url":"https://api.github.com/users/fungilation/followers","following_url":"https://api.github.com/users/fungilation/following{/other_user}","gists_url":"https://api.github.com/users/fungilation/gists{/gist_id}","starred_url":"https://api.github.com/users/fungilation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fungilation/subscriptions","organizations_url":"https://api.github.com/users/fungilation/orgs","repos_url":"https://api.github.com/users/fungilation/repos","events_url":"https://api.github.com/users/fungilation/events{/privacy}","received_events_url":"https://api.github.com/users/fungilation/received_events","type":"User","site_admin":false},"labels":[{"id":1050345450,"node_id":"MDU6TGFiZWwxMDUwMzQ1NDUw","url":"https://api.github.com/repos/react-native-community/react-native-webview/labels/question","name":"question","color":"d876e3","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":46,"created_at":"2018-09-29T22:43:18Z","updated_at":"2018-11-10T10:13:42Z","closed_at":null,"author_association":"NONE","body":"Referencing (my) prior discussions regarding this, for context and so we don't repeat here. In reverse chronological order:\r\n\r\n- https://github.com/alinz/react-native-webview-bridge/issues/109#issuecomment-425669058\r\n- https://github.com/react-native-community/discussions-and-proposals/pull/3#issuecomment-414858049\r\n- https://github.com/facebook/react-native/pull/9762#issuecomment-260583009\r\n\r\nThis consistent, robust, cross platform API is important for any app that blends native and webviews. I list [mine](https://medium.com/wonderswipe/rethink-mobile-search-10-100x-faster-introducing-wonderswipe-6f2ff0d0e667) as one. A requirement of this API is that an injected `postMessage ` for purpose of RN message passing, not be overridden by a website's JS in the WebView. Which is currently the case with RN core's WebView, and presumably this forked react-native-webview. It could be achieved (and have been attempted in prior discussions and in RN core's WebView) by loading RN's injected `postMessage` last, but that's unreliable should the website create after onLoad a function of the same name, alongside iframe issues. This is not hypothetical as it does get overridden for a fact, when loading google.com in WebView for example.\r\n\r\nA simple function rename that doesn't use the web standard of `postMessage` would sidestep what is effectively a name collision issue. Call it `rnPostMessage` or anything else. Open to suggestions on a better alternative to renaming that actually has a guarantee for not being overridden by non-locally loaded JS within WebView.\r\n\r\nThis new API should consider/port code (if tested as reliable) from [react-native-wkwebview](https://github.com/CRAlpha/react-native-wkwebview), which is iOS only. And implement the same API for other platforms. There is also working RN<>WebView bridge API at [react-native-webview-bridge](https://github.com/alinz/react-native-webview-bridge) that's well established (old but fully functional, with google.com loaded in webview, and for Android and iOS), but that's based on UIWebView and not WKWebView on the iOS side."},"comment":{"url":"https://api.github.com/repos/react-native-community/react-native-webview/issues/comments/437573199","html_url":"https://github.com/react-native-community/react-native-webview/issues/66#issuecomment-437573199","issue_url":"https://api.github.com/repos/react-native-community/react-native-webview/issues/66","id":437573199,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzU3MzE5OQ==","user":{"login":"KoenLav","id":12446296,"node_id":"MDQ6VXNlcjEyNDQ2Mjk2","avatar_url":"https://avatars2.githubusercontent.com/u/12446296?v=4","gravatar_id":"","url":"https://api.github.com/users/KoenLav","html_url":"https://github.com/KoenLav","followers_url":"https://api.github.com/users/KoenLav/followers","following_url":"https://api.github.com/users/KoenLav/following{/other_user}","gists_url":"https://api.github.com/users/KoenLav/gists{/gist_id}","starred_url":"https://api.github.com/users/KoenLav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KoenLav/subscriptions","organizations_url":"https://api.github.com/users/KoenLav/orgs","repos_url":"https://api.github.com/users/KoenLav/repos","events_url":"https://api.github.com/users/KoenLav/events{/privacy}","received_events_url":"https://api.github.com/users/KoenLav/received_events","type":"User","site_admin":false},"created_at":"2018-11-10T10:13:42Z","updated_at":"2018-11-10T10:13:42Z","author_association":"NONE","body":"Please take a look at the code, you'll understand what's done from the diff :)\r\n\r\nThis PR does not (yet) offer a way to call functions from WebView to ReactNative. The package I am working on here does: https://github.com/KoenLav/bridged-webview\r\n\r\nTitozzz mentioned he doesn't feel like this should be included in this repository (you and me disagree with him, and think it should), so I left it out of the PR for now.\r\n\r\nThis PR solely focuses on un-breaking things (window.postMessage) and making sure the behavior between iOS and Android is consistent, while maintaining backwards compatibility under a flag.\r\n\r\nIn a later PR I want to work on creating a property on the WebView (injectBridge={true}) which will make the following possible, from the WebView:\r\n\r\nReactNativeBridge.call('nativeFunctionName', arg1, arg2, function(err, res) { console.log(err, res) });\r\n\r\nAs you can see in the BridgedWebview repository."}}
{"actor":{"display_login":"KoenLav"}}