将React Native应用程序嵌入现有的ios/android应用程序中 [英] Embed react native app inside existing ios/android app

查看:161
本文介绍了将React Native应用程序嵌入现有的ios/android应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道是否有可能在不共享React本机应用程序代码的情况下,将React本机应用程序嵌入"到现有的ios/android应用程序中.

我们目前有一个React Native应用程序,该应用程序使用一些插件依赖项,并被问到是否有可能将其嵌入到现有的本机应用程序中(即作为子视图)并使两个部分彼此通信.

我知道可以这样做( https://facebook.github.io/react-native/docs/communication-ios.html ),但我想知道如何在不与需要嵌入应用程序的现有应用程序共享当前代码的情况下实现它./p>

在构建时是否有任何方法可以将其作为捆绑包,小部件嵌入甚至从私人仓库中获取?

谢谢

解决方案

从您链接的文档中:

为了将React Native视图嵌入到本机组件中,我们使用 RCTRootView. RCTRootView是一个拥有React Native应用程序的UIView.它 还提供了本机端与托管应用之间的接口.

您可以生成一个包含此RCTRootView的iOS框架.如果您不想分发源代码,则应该能够分发二进制框架.

I need to know if it is possible to "embed" a react native app within an existing ios/android app without sharing the react native app code.

We currently have a react native app which use a few plugins dependencies and was asked if it would be possible to embed it within an existing native app (i.e. as a subview) and make both parts communicate with each other.

I know it is possible to do it (https://facebook.github.io/react-native/docs/communication-ios.html) but I'm rather wondering how to achieve it without sharing our current code with the existing app that needs our app to be embedded.

Is there any way to embed it as a bundle, a widget or even grab it from a private repo while building?

Thanks

解决方案

From the documentation you linked:

In order to embed a React Native view in a native component, we use RCTRootView. RCTRootView is a UIView that holds a React Native app. It also provides an interface between native side and the hosted app.

You can produce an iOS Framework that includes this RCTRootView. You should be able to distribute the binary framework if you don't want to distribute the source.

这篇关于将React Native应用程序嵌入现有的ios/android应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆