This is React Native Bluetooth Low Energy library wrapping Multiplatform Ble Adapter.
It supports:
- observing device's Bluetooth adapter state
- scanning BLE devices
- making connections to peripherals
- discovering services/characteristics
- reading/writing characteristics
- observing characteristic notifications/indications
- reading RSSI
- negotiating MTU
- background mode on iOS
- turning the device's Bluetooth adapter on
It does NOT support:
- bluetooth classic devices.
- communicating between phones using BLE (Peripheral support)
- bonding peripherals
For old RN versions (<0.60) please check old README (1.x) for the old instructions or migration guide.
React Native | 3.0.0 |
---|---|
0.72.4 | ✅ |
0.71.13 | ✅ |
0.70.13 | ✅ |
3.0.0
- Added Example project
- Updated MultiplatformBleAdapter to version 0.2.0.
- Updated RN bridge config
- Changed CI flow
- Updated CI to RN 0.72.x
- Updated docs
- Updated dependencies
- Fixed iOS 16 bugs
Current version changes All previous changes
Interested in React Native project involving Bluetooth Low Energy? We can help you!
Documentation can be found here.
Quick introduction can be found here
Contact us at intent.
- A custom expo-dev-client can now be built along with config plugins to avoid the need to eject from Expo. Learn how to integrate react-native-ble-plx with Expo here. (only for expo SDK 43+)
- Make sure your Expo project is ejected (formerly: detached). You can read how to do it here. (only for Expo SDK < 43)
- Follow steps for iOS/Android.
iOS (example setup)
npm install --save react-native-ble-plx
- Enter
ios
folder and runpod update
- Add
NSBluetoothAlwaysUsageDescription
ininfo.plist
file. (it is a requirement since iOS 13) - If you want to support background mode:
- In your application target go to
Capabilities
tab and enableUses Bluetooth LE Accessories
inBackground Modes
section. - Pass
restoreStateIdentifier
andrestoreStateFunction
toBleManager
constructor.
- In your application target go to
Android (example setup)
-
npm install --save react-native-ble-plx
-
In top level
build.gradle
make sure that min SDK version is at least 23:buildscript { ext { ... minSdkVersion = 23 ...
-
In
build.gradle
make sure to add jitpack repository to known repositories:allprojects { repositories { ... maven { url 'https://www.jitpack.io' } } }
-
In
AndroidManifest.xml
, add Bluetooth permissions and update<uses-sdk/>
:<manifest xmlns:android="http://schemas.android.com/apk/res/android"> ... <!-- Android >= 12 --> <uses-permission android:name="android.permission.BLUETOOTH_SCAN" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> <!-- Android < 12 --> <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" /> <!-- common --> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- Add this line if your application always requires BLE. More info can be found on: https://developer.android.com/guide/topics/connectivity/bluetooth-le.html#permissions --> <uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/> ...
-
(Optional) In SDK 31+ You can remove
ACCESS_FINE_LOCATION
(or mark it asandroid:maxSdkVersion="30"
) fromAndroidManifest.xml
and addneverForLocation
flag intoBLUETOOTH_SCAN
permissions which says that you will not use location based on scanning eg:<uses-permission android:name="android.permission.INTERNET" /> <!-- Android >= 12 --> <uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> <!-- Android < 12 --> <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" /> ...
With
neverForLocation
flag active, you no longer need to ask forACCESS_FINE_LOCATION
in your app