Files
config-plugins/packages/react-native-ble-plx
Evan Bacon d6050beb2a chore: git ignore build folders (#59)
* chore: git ignore all package build folders in git

* chore: clear all package build folders
2022-03-22 13:27:18 -05:00
..
2021-07-20 23:56:56 -06:00
2022-03-16 00:20:24 +00:00
2022-03-16 00:20:24 +00:00

config-plugins/react-native-ble-plx

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

Expo installation

Tested against Expo SDK 44

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

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.
  • 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.
  • bluetoothPeripheralPermission (string | false): Sets the iOS NSBluetoothPeripheralUsageDescription permission message to the Info.plist. Setting false will skip adding the permission. Defaults to Allow $(PRODUCT_NAME) to connect to bluetooth devices.

Example

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