简体   繁体   English

将现有的WebView JavascriptInterface与React-Native一起使用

[英]Use existing WebView JavascriptInterface with React-Native

Can I use existent javascript interface, currently attached to the WebView in my android and iOS projects, within React-Native app? 我可以在React-Native应用程序中使用我的android和iOS项目中当前附加到WebView的现有javascript接口吗?

React-Native does not use WebView for itself to run. React-Native本身并不使用WebView来运行。 But I can create it React WebView . 但是我可以创建它React WebView My question is about using existing javascript interface, perhabs attach it to the created in React-Native WebView, make some sort of React extension etc... 我的问题是关于使用现有的javascript接口,将其附加到在React-Native WebView中创建的,进行某种React扩展等...

BACKGROUND: 背景:

I have several android and ios applications made using WebView. 我有几个使用WebView制作的android和ios应用程序。 For WebView there is a javascript interface (same for all apps), that I use to access native device environment features (like Cordova/Phonegap) and third party SDKs and libraries (one o them is an SDK for Augmented Reality), so my javascript "bridge" handle all those API calls. 对于WebView,有一个javascript界面​​(所有应用程序都相同),我使用它来访问本机设备环境功能(例如Cordova / Phonegap)以及第三方SDK和库(其中一个是用于增强现实的SDK),所以我的javascript “桥”处理所有这些API调用。

Every single app is made then within WebView environment (here I can use a variety of js libraries and frameworks like AngulerJS, JQuery etc...). 然后,每个单独的应用程序都是在WebView环境中制作的(这里我可以使用各种js库和框架,例如AngulerJS,JQuery等)。 My apps look like a transparent html body, camera image behind it with augmented reality 3d scene (3d models and 3d interfaces), other html views used for texts, images, lists, forms, popups, dialogs and so on. 我的应用程序看起来像一个透明的html主体,其后面带有增强现实3d场景(3d模型和3d界面)的照相机图像,其他用于文本,图像,列表,表单,弹出窗口,对话框等的html视图。

This stack i quite solid and i made a lot of apps with it. 这个堆栈我很扎实,我用它做了很多应用程序。

Then I found React-Native and i thought about realizing the "2D" part (that was always made in HTML) using native mobile components. 然后,我找到了React-Native,并考虑使用本地移动组件实现“ 2D”部分(始终以HTML制作)。 So the question is: is it even possible to use my javascript "bridge" in React-Native context? 所以问题是:甚至有可能在React-Native上下文中使用我的javascript“ bridge”吗? I mean this "bridge" is attached to the WebView, what if I could transform it somehow to use with React-Native? 我的意思是这个“桥梁”附加到了WebView上,如果我能以某种方式将其转换成与React-Native一起使用怎么办?

No, you can't. 不,你不能。 React Native does not use WebViews under the hood but normal iOS / Android UI Components. React Native不使用WebViews,而是使用普通的iOS / Android UI组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM