Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

react-native-ble-plx

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-ble-plx

React Native Bluetooth Low Energy library

Source
npmnpm
Version
2.0.1
Version published
Weekly downloads
96K
17.79%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-ble-plx library logo

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 Native2.0.0
0.62.2:white_check_mark:
0.61.5:white_check_mark:
0.60.6:white_check_mark:

Recent Changes

2.0.1

  • Fixed onDisconnected() callback on Android
  • Fixed possibility of wrong characteristics being used on Android if they shared the same UUID

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

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

iOS (example setup)

  • npm install --save react-native-ble-plx
  • npx react-native link react-native-ble-plx
  • 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.
  • Update your ios/Podfile to contain (it may be already there):
    pod 'react-native-ble-plx', :path => '../node_modules/react-native-ble-plx'
    
  • Enter ios folder and run pod update
  • Add NSBluetoothAlwaysUsageDescription in info.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 enable Uses Bluetooth LE Accessories in Background Modes section.
    • Pass restoreStateIdentifier and restoreStateFunction to BleManager constructor.

Android (example setup)

  • npm install --save react-native-ble-plx
  • npx react-native link react-native-ble-plx
  • In top level build.gradle make sure that min SDK version is at least 18:
buildscript {
    ext {
        ...
        minSdkVersion = 18
        ...
  • 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"
    ...
    <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.**

Keywords

React

FAQs

Package last updated on 30 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts