React Native Bluetooth Low Energy library using RxBluetoothKit and RxAndroidBle as it's backend libraries.
Example apps are available in Google Play and App Store!
0.4.0
- Device ID properties were renamed as they are not UUIDs on Android (breaking change):
Device.uuid->Device.idService.deviceUUID->Service.deviceID,Characteristic.deviceUUID->Characteristic.deviceID
- Changed signature of
onDeviceDisconnected, as Device object is always available. - Updated to Swift 3.0
- Updated to RxAndroidBle 1.1.0 and RxBluetoothKit 3.0.6
- Documentation was moved to
./docfolder and now is generated by ESDoc. - Fixed
state()invalid return type. Implementedstate()andonStateChange()for Android. - Added optional parameter to
onStateChange()function. - Fixed
monitorCharacteristicForDevice()for Android when characteristic accepts indications only. - Updated
AndroidManifest.xmlconfiguration.
Documentation can be found under ./doc folder.
iOS:
- Add
react-native-ble-plxto a project as a dependency inpackage.jsonfile. For example"react-native-ble-plx": "Polidea/react-native-ble-plx"will install latest version from Polidea's Github repository. - Make sure that you have Carthage installed on your system.
- Execute
npm installto fetch and install a library. - Open iOS project located in
./iosfolder. - Move
BleClient.xcodeprojlocated in.node_modules/react-native-ble-plx/iosusing drag & drop toLibrariesfolder in your project. - In general settings of a target add
libBleClient.ato Linked Frameworks and Libraries. - In
Build Settings/Search Paths/Framework search pathsadd path:$(SRCROOT)/../node_modules/react-native-ble-plx/ios/BleClientManager/Carthage/Build/iOS. - In
Build Settings/Build Options/Always Embed Swift Standard Librariesset toYes. - In
Build Phasesclick on top left button and addNew Run Script Phase.- Shell command:
/usr/local/bin/carthage copy-frameworks - Input Files:
$(SRCROOT)/../node_modules/react-native-ble-plx/ios/BleClientManager/Carthage/Build/iOS/BleClientManager.framework$(SRCROOT)/../node_modules/react-native-ble-plx/ios/BleClientManager/Carthage/Build/iOS/RxSwift.framework$(SRCROOT)/../node_modules/react-native-ble-plx/ios/BleClientManager/Carthage/Build/iOS/RxBluetoothKit.framework
- Shell command:
- Minimal supported version of iOS is 8.0
Android:
- Add
react-native-ble-plxto a project as a dependency inpackage.jsonfile. For example"react-native-ble-plx": "Polidea/react-native-ble-plx"will install latest version from Polidea's Github repository. - Execute
npm installto fetch and install a library. - Open Android project located in
./androidfolder. - In
settings.gradleadd following lines:
include ':react-native-ble-plx'
project(':react-native-ble-plx').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-ble-plx/android')- In
build.gradleofappmodule add following dependency:
dependencies {
...
compile project(':react-native-ble-plx')
...- Additionaly make sure that min SDK version is at least 18:
android {
...
defaultConfig {
minSdkVersion 18
...- In
MainApplication.getPackagesimport and add BleModule package:
import com.polidea.reactnativeble.BlePackage;
...
public class MainApplication extends Application implements ReactApplication {
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new BlePackage()
);
}- In
AndroidManifest.xmladd Bluetooth permissions and update<uses-sdk/>:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission-sdk-23 android:name="android.permission.ACCESS_COARSE_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"/>
<uses-sdk
android:minSdkVersion="18"
...


