Skip to content

A fork of expo/config-plugins in order to use @config-plugins/react-native-ble-plx with a version of expo > 49

Notifications You must be signed in to change notification settings

ReperioHealth/reperio-config-plugins-react-native-ble-plx

 
 

Repository files navigation

⚠️ A note to current and future people wondering why this repo exists ⚠️

In our expo migration there were issues with the latest version of [email protected] not working properly out of the box, so we kept using the working 2.x react-native-ble-plx, which required the use of config-plugins/react-native-ble-plx. Unfortunately that config plugin has an <= expo 49 peerDependency because the newer versions of react-native-ble-plx include the config plugin in the package. Once we are able to use the newer react-native-ble-plx versions with the included config plugin, we can delete this abomination.


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 @reperiohealth/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": ["@reperiohealth/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": [
      [
        "@reperiohealth/config-plugins-react-native-ble-plx",
        {
          "isBackgroundEnabled": true,
          "modes": ["peripheral", "central"],
          "bluetoothAlwaysPermission": "Allow $(PRODUCT_NAME) to connect to bluetooth devices"
        }
      ]
    ]
  }
}

About

A fork of expo/config-plugins in order to use @config-plugins/react-native-ble-plx with a version of expo > 49

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 58.6%
  • JavaScript 41.4%