React Native Bluetooth Low Energy library

React Native Bluetooth Low Energy library

This is React Native Bluetooth Low Energy library wrapping Multiplatform Ble Adapter.

About this library

This is React Native Bluetooth Low Energy library wrapping Multiplatform Ble Adapter.

It supports:

It does NOT support:

  • bluetooth classic devices.
  • communicating between phones using BLE (Peripheral support)
  • bonding peripherals

Compatibility

This version (2.x) breaks compatibility with old RN versions. Please check old README (1.x) for the old instructions or migration guide.

React Native 2.0.0
0.62.2
0.61.5
0.60.6

Recent Changes

2.0.0

  • Update direct dependency to Multiplatform Ble Adapter
  • Remove support for RN version < 0.60
  • Fixed Typescript callbackType type definition.

All previous changes

Documentation & Support

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

Learn more about Polidea's React Native services.

Learn more about Polidea's BLE services.

Documentation can be found here.

Contact us at Polidea.

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

Configuration & Installation

Expo

  1. Make sure your Expo project is ejected (formerly: detached). You can read how to do it here and here. (only for expo)
  2. Follow steps for iOS/Android.

iOS (example setup)

  1. npm install --save react-native-ble-plx

  2. npx react-native link react-native-ble-plx

  3. Open Xcode workspace located inside ios folder and 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.
  4. Update your ios/Podfile to contain (it may be already there):

    pod 'react-native-ble-plx', :path => '../node_modules/react-native-ble-plx'
    
  5. Enter ios folder and run pod update

  6. Add NSBluetoothAlwaysUsageDescription in info.plist file. (it is a requirement since iOS 13)

  7. 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 (example setup)

  1. npm install --save react-native-ble-plx
  2. npx react-native link react-native-ble-plx
  3. In top level build.gradle make sure that min SDK version is at least 18:
buildscript {
    ext {
        ...
        minSdkVersion = 18
        ...
  1. In build.gradle make sure to add jitpack repository to known repositories:
allprojects {
    repositories {
      ...
      maven { url 'https://www.jitpack.io' }
    }
}
  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_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"/>

    ...

Troubleshooting

Problems with Proguard

Add this to your app/proguard-rules.pro

-dontwarn com.polidea.reactnativeble.**

Download Details:

Author: Polidea

GitHub: https://github.com/Polidea/react-native-ble-plx

react-native react mobile-app

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

React Native Mobile App Development

Skenix is providing React Native Development Services with qualified React Native App Developers. Get the best React Native App Development Services.

Top React Native Mobile App Development Companies in USA

Looking for top React Native mobile app development company in USA for Startups & Enterprise? Find out the top list of React Native mobile app development company in USA.

Which is the best React Native app development company in New York?

Hire top react native app development company in New York to build and develop custom react native mobile apps for Android & iOS with the latest features.

Create React Native eCommerce Mobile App

Find out how to build eCommerce mobile application with React Native. Tips and tricks to save time, efforts, and money.