-
Notifications
You must be signed in to change notification settings - Fork 184
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
Access Node directly from React Native Webview #124
Comments
Hi @KoenLav , You won't be able to communicate with Node directly from the Webview: https://github.com/janeasystems/nodejs-mobile/blob/a9208805aa3bdc6dace6f7db88a3db6e398d11fd/FAQ.md#can-i-run-nodejs-code-in-a-webview Regarding accessing the bridge from a WebView, you'd have to look at the WebView API to see how to call native code from it and call the bridge functions. Cordova runs in a WebView, so looking at the Cordova and nodejs-mobile-cordova plugin code could be a good place to start. I don't think I have any more tips for this, since it's not the supported scenario and hasn't been done yet, as far as I'm aware. |
@jaimecbernardo thanks for your feedback! I understand I won't be able to call out to Node.js directly (maybe I didn't make that clear). In Electron IPC (Inter Process Communication) is used, also with channels (similarly to how React Native handles postMessage etc, I thought). And I guessed React Native => Node.js would make use of a similar technique. So right now WebView => React Native = > Node.js would already be possible. I was wondering, if these => represent similar techniques, whether we could create something like WebView => Node.js (without it actually passing through React Native). |
Hi @KoenLav , That's what is used in Cordova (WebView => Cordova native code => Node.js), so it could be possible, if the react-native WebView API allows you to call into native code on both platforms. I'm not familiar enough with the react-native WebView to be sure of it. |
The React Native WebView definitely supports the way you just described, and this should be doable right now. However I was wondering whether it would be possible to send messages from the WebView directly to the Node.js process. I now understand this is more of a question of the WebView supporting this, so I'll present the message there! |
I was wondering whether it would be possible to communicate with Node directly from a webview in React Native.
I know the webview is also capable of using the IPC route (react native webview bridge), so I guess it should be possible, but I'm looking for advice on how to implement this.
Any insights would be greatly appreciated!
The text was updated successfully, but these errors were encountered: