Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer 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
1.1.0
Version published
Weekly downloads
105K
12.1%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-ble-plx library logo

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:

Compatibility

React Native1.0.31.1.0
0.60.5:white_check_mark::white_check_mark:
0.59.10:white_check_mark::white_check_mark:
0.58.6:white_check_mark::white_check_mark:
0.57.8:white_check_mark::white_check_mark:
0.56.1:boom:1:boom:1
0.55.4:boom:1:boom:1

1 fails on Android, although might work after updating gradle

Recent Changes

1.1.0

  • Add support for descriptors.
  • Fix XCode 11 compilation error.

All previous changes

Documentation & Support

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

Learn more about Polidea's BLE services here.

Documentation can be found here.

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

Configuration & Installation

iOS (expo/Podfile and RN 0.60+, example setup)

  • Make sure your Expo project is ejected (formerly: detached). You can read how to do it here and here. (only for expo)
  • npm install --save react-native-ble-plx
  • react-native link react-native-ble-plx
  • 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:
    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'
    
  • Enter ios folder and run pod update
  • Minimal supported version of iOS is 8.0
  • 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 (react-native < 0.60, example setup)

  • npm install --save react-native-ble-plx

  • react-native link react-native-ble-plx

  • 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.
  • Minimal supported version of iOS is 8.0

  • 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
  • react-native link react-native-ble-plx
  • In build.gradle of app module make sure that min SDK version is at least 18:
android {
    ...
    defaultConfig {
        minSdkVersion 18
        ...
  • 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"
        ...
  • If you are using AndroidX, then for the time being you need to convert import statements in the Android library with jetifier. These steps apply for all react-native packages, which are during the transition period:
  • npm install --save-dev jetifier
  • Run jetify script after npm install. You can do it by adding "postinstall" script to the package.json file:
     ...
     "postinstall": "npx jetify",
     ...
    

Troubleshooting

Problems with Proguard

Add this to your app/proguard-rules.pro

-dontwarn com.polidea.reactnativeble.**

Keywords

React

FAQs

Package last updated on 12 Sep 2019

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