@mankin/expo-mods-ble
v0.0.5
Published
Config plugin to auto configure ble permission on prebuild
Downloads
4
Readme
expo-mods-ble
Fork from: config-plugins/react-native-ble-plx
Config plugin to auto-configure ble permission when the native code is generated (expo prebuild
).
Expo installation
npm install -D @mankin/expo-mods-ble
Tested against Expo SDK 46.
This package cannot be used in the "Expo Go" app because it requires custom native code. First install the package with pnpm, yarn, npm, or
expo install
.
After installing this npm package, add the config plugin to the plugins
array of your app.json
or app.config.js
:
{
"expo": {
"plugins": ["@mankin/expo-mods-ble"]
}
}
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 theAndroidManifest.xml
. Defaultfalse
.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+. Defaultfalse
. WARNING: This parameter is experimental and BLE might not work. Make sure to test before releasing to production.modes
(string[]): Adds iOSUIBackgroundModes
to theInfo.plist
. Options are:peripheral
, andcentral
. Defaults to undefined.bluetoothAlwaysPermission
(string | false): Sets the iOSNSBluetoothAlwaysUsageDescription
permission message to theInfo.plist
. Settingfalse
will skip adding the permission. Defaults toAllow $(PRODUCT_NAME) to connect to bluetooth devices
.bluetoothPeripheralPermission
(string | false): Sets the iOSNSBluetoothPeripheralUsageDescription
permission message to theInfo.plist
. Settingfalse
will skip adding the permission. Defaults toAllow $(PRODUCT_NAME) to connect to bluetooth devices
.
Example
{
"expo": {
"plugins": [
[
"@mankin/expo-mods-ble",
{
"isBackgroundEnabled": true,
"modes": ["peripheral", "central"],
"bluetoothAlwaysPermission": "Allow $(PRODUCT_NAME) to connect to bluetooth devices",
"bluetoothPeripheralPermission": "Allow $(PRODUCT_NAME) to connect to bluetooth devices"
}
]
]
}
}