React Native BLE library
Swift JavaScript Java Objective-C Groovy Ruby
Clone or download
Latest commit 9aace3a Jul 27, 2018
Permalink
Failed to load latest commit information.
.vscode Update dependencies and format code with latest prettier. Oct 24, 2017
__tests__ Rename BleErrorCodeDescription to BleErrorCodeMessage. Add more info … Mar 16, 2018
android Add missing deviceServicesNotDiscovered implementation on Android. Jul 26, 2018
docs Update graphics used in README file. Jul 26, 2018
examples/Sniffator Replaced old example app with new project with reused app identifiers… Dec 7, 2017
ios Update pod spec files. Jul 27, 2018
src Fix error.message visibility on iOS. Jul 20, 2018
.babelrc Update dependencies and format code with latest prettier. Oct 24, 2017
.eslintrc.json Update dependencies and format code with latest prettier. Oct 24, 2017
.flowconfig Updated dev dependencies to check flow errors with RN 0.56 Jul 18, 2018
.gitignore Update AndroidBle library and source code to deviceId changes. Jan 27, 2017
.npmignore Add basic tests for JS functionality. May 21, 2017
CHANGELOG.md Add missing deviceServicesNotDiscovered implementation on Android. Jul 26, 2018
INTRO.md Added missing importing of BleManager in the docs Jan 3, 2018
LICENSE Updated copyright statement Jul 28, 2016
README.md Update expo instructions for iOS. Jul 27, 2018
documentation.yml Add documentation to error codes. Mar 16, 2018
index.js Initial description of BLE errors. Mar 16, 2018
jsconfig.json Update dependencies and format code with latest prettier. Oct 24, 2017
package-lock.json Update lock files. Jul 27, 2018
package.json Remove post install script and bump package.json version to 0.10.0. Jul 20, 2018
react-native-ble-plx-swift.podspec Update expo project configuration. Jul 27, 2018
react-native-ble-plx.podspec Update pod spec files. Jul 27, 2018
yarn.lock Update lock files. Jul 27, 2018

README.md

react-native-ble-plx

About this library

This is React Native Bluetooth Low Energy library using RxBluetoothKit and RxAndroidBle under the hood.

It supports:

What this library does NOT support:

  • turning the device's Bluetooth adapter on
  • communicating between phones using BLE (Peripheral support)
  • bonding peripherals

Recent Changes

0.10.0

Breaking changes:

  • Deprecate old build system. Carthage is not required anymore. To fix your current project please do following steps:

    1. Add empty Swift file if you don't have at least one:
      • Select File/New/File...
      • Choose Swift file and click Next.
      • Name it however you want, select your targets and create it.
      • Accept to create Objective-C bridging header.
    2. Remove copy-frameworks script if you don't have any other dependency requiring it:
      • Go to Your Target / Build Phases
      • Remove run script.

Other:

  • Fix warning when no listeners were attached and events were emitted.
  • Show error.message properly. Make sure that invalid errorCodes from implementation side won't trigger another error during construction.
  • Property ServiceUUID is properly propagated to IncludedServicesDiscoveryFailed's error message.
  • Add missing deviceServicesNotDiscovered implementation on Android.

All previous changes

Documentation & Support

Interested in React Native project involving Bluetooth Low Energy? We can help you!

Documentation can be found here.

Contact us at Gitter if you have any questions, feedback or want to help!

Configuration & Installation

iOS (pure react-native)

  1. npm install --save react-native-ble-plx
  2. react-native link react-native-ble-plx
  3. Add empty Swift file if you don't have at least one:
    • Select File/New/File...
    • Choose Swift file and click Next.
    • Name it however you want, select your targets and create it.
    • Accept to create Objective-C bridging header.
  4. Minimal supported version of iOS is 8.0
  5. If you want to support background mode:
    • In your application target go to Capabilities tab and enable Uses Bluetooth LE Accessories in Background Modes section.
    • Pass restoreStateIdentifier and restoreStateFunction to BleManager constructor.

iOS (expo/Podfile)

  1. Make sure your Expo project is detached. You can read how to do it here and here.
  2. npm install --save react-native-ble-plx
  3. react-native link react-native-ble-plx
  4. Add empty Swift file if you don't have at least one:
    • Select File/New/File...
    • Choose Swift file and click Next.
    • Name it however you want, select your application target and create it.
    • Accept to create Objective-C bridging header.
  5. Update your ios/Podfile to contain:
    pod 'react-native-ble-plx', :path => '../node_modules/react-native-ble-plx'
    pod 'react-native-ble-plx-swift', :path => '../node_modules/react-native-ble-plx'
    
  6. Enter ios folder and run pod update
  7. Minimal supported version of iOS is 8.0
  8. If you want to support background mode:
    • In your application target go to Capabilities tab and enable Uses Bluetooth LE Accessories in Background Modes section.
    • Pass restoreStateIdentifier and restoreStateFunction to BleManager constructor.

Android

  1. npm install --save react-native-ble-plx
  2. react-native link react-native-ble-plx
  3. In build.gradle of app module make sure that min SDK version is at least 18:
android {
    ...
    defaultConfig {
        minSdkVersion 18
        ...
  1. In AndroidManifest.xml, add 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"
        ...

Troubleshooting

Problems with Proguard

Add this to your app/proguard-rules.pro

-dontwarn com.polidea.reactnativeble.**