-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WebView] Message passing between WebView / Javascript #586
Comments
+1. That would be quite handy indeed. |
+1, also fits my use case. |
I came up this hacky approach to send message from the webview's HTML back to the react native.
|
We can also just run all of the ReactNative JS in a WKWebView - would that make PouchDB happy? We could potentially make the executor mode configurable per app so you could use that instead of JSC if you prefer that tradeoff (more latency, probably more memory, etc). |
@sahrens Even if we do that, I'm not sure if we'd want to allow access to all DOM APIs? I'm don't think that running incompatible libraries in a headless web view is likely the right solution, but there certainly are cases where you'd want to have something in a web view and pass messages to it, so maybe we could add something here. |
@notduncansmith - any interest in this still? if so, a PR would be welcome! you can ping me on irc/twitter @notbrent (nice username, by the way) if you need a hand |
I had a go at this, and I got basic messages working using the techniques described at the Stackoverflow page. However, I was wondering how Apple would look at this feature since it allows remote websites execute code (sort of). Titanium seems to allow communication if the code is loaded from a local source (http://docs.appcelerator.com/titanium/3.0/#!/guide/Communication_Between_WebViews_and_Titanium). Any thoughts on this? |
@Intellicode - it seems like Titanium allows some actions to be triggered on remote sites as well - that said, I think the best angle here is to pull this out into an external library where we can discuss it and iterate on it and when it is mature enough potentially integrating it back into React Native. Are you willing to do that? It would be awesome 😄 |
I'll have a go at it this weekend, should be a good learning opportunity :) |
I was able to get this to work: https://github.com/alinz/react-native-webview-bridge The example included in the repo was more helpful than the docs. UPDATE: Be aware of this issue - alinz/react-native-webview-bridge#3 |
nice, I guess I can stop working on my version then :) |
@ide @brentvatne Issue can be closed. |
I really wish this was built-in in WebView, |
@spicyj
Thanks |
I don't know. I don't work actively on React Native. Generally, if things haven't been implemented it means that there hasn't been much demand at Facebook for a feature and often means that there hasn't been much demand externally either. This is a community project and if you want to improve the components, please send pull requests. |
@spicyj Thanks :) |
Is there any way to implement a callback of WebView in JS? E.g. in Android |
@pglotov I recommand to use https://github.com/alinz/react-native-webview-bridge . for the moment it's only for iOS but see in issues, someone has worked on an android version. |
@gre thanks, interesting stuff. But seems like an overkill for my purpose. I'll try to make the |
+1 for shouldOverrideUrlLoding on Android |
+1 for shouldOverrideUrlLoading on Android |
2 similar comments
+1 for shouldOverrideUrlLoading on Android |
+1 for shouldOverrideUrlLoading on Android |
+1 for |
Implemented |
I want to use the Web Cryptography API ( I have limited experience with React Native, so I am unsure if there is a faster/simpler way of achieving this. |
This issue should be reopened as https://github.com/alinz/react-native-webview-bridge no longer works with the latest version of react-native, and the author is no longer supporting it as he's pushing to get it implemented into RN core. |
Hi, |
I would really like to see this issue opened. It should be a core feature. |
Already in v0.37.0. See this issue. |
Hi, |
It would be really great to be able to run JS inside of a WebView component and register event listeners within regular React Native code.
My specific use-case is PouchDB, which really wants to run either in Node.js or the browser; however, there are lots of libraries that are designed to work within one or the other of the existing JS runtimes, but would still be useful to a React Native app.
I'm thinking something along these lines, perhaps register a
react://
protocol or something for message passing - though I'd love to hear about a cleaner way to implement it.The text was updated successfully, but these errors were encountered: