From a69b81502a0b87c217c3abc33e0d6548974e66b7 Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Fri, 25 Oct 2019 12:09:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=A6=82=E4=BD=95=E5=B1=8F?= =?UTF-8?q?=E8=94=BDios=E7=AB=AF=E7=9A=84=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 21 +++++++++++++++++++++ lib/index.js | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 650ad61..bd32ff0 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,27 @@ 本组件是面向 React Native 提供热更新功能的组件,建议结合[Update 服务](https://update.reactnative.cn/)使用。 +注意,在iOS上使用热更新有被拒的可能。可以按以下步骤屏蔽iOS端: + +1. 如果RN版本>=0.60,在项目根目录下编辑或创建react-native.config.js,添加如下内容 +```js +// react-native.config.js +module.exports = { + dependencies: { + 'react-native-update': { + platforms: { + ios: null, // 阻止ios模块自动链接 + }, + }, + }, +}; +``` +2. 如果在原生代码端尚未配置,则跳过下面文档中的ios端的配置。如果已经配置,则按文档的步骤反向操作(添加的ios代码删去)。 +3. 如果是0.60以上版本或使用了cocoapods,在ios目录中再次运行pod install,确保Podfile和Podfile.lock中都没有'react-native-update'。如果RN版本<0.60,则运行`react-native unlink react-native-update`。 +4. 在js代码里调用checkUpdate()方法前,判断Platform.OS,如果是ios平台则直接return跳过。 +``` + + ### 最近更新 请查阅[最近更新文档](CHANGELOG.md)。 diff --git a/lib/index.js b/lib/index.js index f709ffd..3c777bb 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,5 +1,5 @@ import { NativeAppEventEmitter, NativeModules } from 'react-native'; -const { HotUpdate } = NativeModules; +const { HotUpdate = {} } = NativeModules; const host = 'https://update.reactnative.cn/api';