【问题标题】:How can we load react native bundles globally我们如何在全球范围内加载反应原生包
【发布时间】:2022-01-24 23:18:52
【问题描述】:

通过 expo 项目,我们可以启动捆绑包并将 ** CONNECTION** 更改为开发者工具中的隧道,以便全局加载捆绑包。我们如何为 react-native 项目全局加载包?我尝试使用公共 IP 地址,但捆绑包需要连接到同一网络。

【问题讨论】:

    标签: react-native expo bundles packager


    【解决方案1】:

    基于CodePush的实现。您应该能够通过本机代码从其远程位置下载捆绑包,并通过覆盖MainApplication.javagetJSBundle() 方法返回其位置。

    // Override the getJSBundleFile method to let
    // your runtime determine where to get the JS
    // bundle location from on each app start
    @Override
    protected String getJSBundleFile() {
      // your implementation here
    }
    

    通过覆盖 AppDelegate.msourceURLForBridge 方法,使用 Objective-C 实现 iOS 的相同方法:

    - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
    {
      // your implementation here
    }
    

    虽然对于 react-native 包必须在本地可用,但您的本机代码可以下载旧包并将其交换为新包,然后返回新包的位置。

    【讨论】:

    • 你试过了吗?
    • 我还没来得及尝试使用自定义实现,但这就是 CodePush 的做法。如果你不介意我问你到底想完成什么?
    猜你喜欢
    • 2018-03-22
    • 2016-02-06
    • 1970-01-01
    • 1970-01-01
    • 2020-01-22
    • 2022-08-10
    • 2015-05-31
    • 2021-04-28
    • 2020-07-11
    相关资源
    最近更新 更多