@config-plugins/react-native-ble-plx

中文文档
7.0.0发布于 2023/07/15TypeScriptCommonJS零依赖近 30 天下载 8312

Config plugin to auto configure react-native-ble-plx on prebuild

此软件包已被标记为弃用

react-native-ble-plx@>=3.1.1 now ships with an Expo config plugin.

原始使用文档

config-plugins/react-native-ble-plx

Config plugin to auto-configure react-native-ble-plx when the native code is generated (npx expo prebuild). Upstream PR.

Expo installation

Tested against Expo SDK 49

This package cannot be used in the "Expo Go" app because it requires custom native code. First install the package with yarn, npm, or npx expo install.

npx expo install react-native-ble-plx @config-plugins/react-native-ble-plx

After installing this npm package, add the config plugin to the plugins array of your app.json or app.config.js:

{
  "expo": {
    "plugins": ["@config-plugins/react-native-ble-plx"]
  }
}

Next, rebuild your app as described in the "Adding custom native code" guide.

API

The plugin provides props for extra customization. Every time you change the props or plugins, you'll need to rebuild (and prebuild) the native app. If no extra properties are added, defaults will be used.

  • isBackgroundEnabled (boolean): Enable background BLE support on Android. Adds <uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/> to the AndroidManifest.xml. Default false.
  • neverForLocation (boolean): Set to true only if you can strongly assert that your app never derives physical location from Bluetooth scan results. The location permission will be still required on older Android devices. Note, that some BLE beacons are filtered from the scan results. Android SDK 31+. Default false. WARNING: This parameter is experimental and BLE might not work. Make sure to test before releasing to production.
  • modes (string[]): Adds iOS UIBackgroundModes to the Info.plist. Options are: peripheral, and central. Defaults to undefined.
  • bluetoothAlwaysPermission (string | false): Sets the iOS NSBluetoothAlwaysUsageDescription permission message to the Info.plist. Setting false will skip adding the permission. Defaults to Allow $(PRODUCT_NAME) to connect to bluetooth devices.

Expo SDK 48 supports iOS 13+ which means NSBluetoothPeripheralUsageDescription is fully deprecated. It is no longer setup in @config-plugins/[email protected] and greater.

Example

{
  "expo": {
    "plugins": [
      [
        "@config-plugins/react-native-ble-plx",
        {
          "isBackgroundEnabled": true,
          "modes": ["peripheral", "central"],
          "bluetoothAlwaysPermission": "Allow $(PRODUCT_NAME) to connect to bluetooth devices"
        }
      ]
    ]
  }
}

版本与发布记录

@config-plugins/react-native-ble-plx 共发布 13 个版本,首次发布于 2021/06/25;过去 12 个月发布了 0 个版本。

版本发布日期距今
7.0.0latest2023/07/153 年前
6.0.02023/03/083 年前
5.0.02022/12/173 年前
4.0.02022/11/173 年前
3.0.02022/08/084 年前
2.0.12022/07/254 年前

关于 @config-plugins/react-native-ble-plx 的常见问题

@config-plugins/react-native-ble-plx 是什么?

Config plugin to auto configure react-native-ble-plx on prebuild注意:该包已被作者标记为弃用——react-native-ble-plx@>=3.1.1 now ships with an Expo config plugin.

如何安装 @config-plugins/react-native-ble-plx?

在项目目录运行 npm install @config-plugins/react-native-ble-plx,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:expo(^49)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@config-plugins/react-native-ble-plx 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@config-plugins/react-native-ble-plx 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@config-plugins/react-native-ble-plx 可以商用吗?

@config-plugins/react-native-ble-plx 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@config-plugins/react-native-ble-plx 的下载量有多少?

根据 npm 官方下载统计,@config-plugins/react-native-ble-plx 在 2026/10/11 – 2026/11/09 这 30 天内被下载 8,312 次,日均约 277 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@config-plugins/react-native-ble-plx 还在维护吗?

最新版本 7.0.0 发布于 2023/07/15(3 年前);至今共发布 13 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/06/25。作者已将其标记为弃用,新项目建议寻找替代方案。