GithubHelp home page GithubHelp logo

aidenzuk / react-native-ble-plx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dotintent/react-native-ble-plx

0.0 1.0 0.0 1.2 MB

React Native BLE library

License: Apache License 2.0

Java 41.75% Groovy 5.72% Shell 0.29% JavaScript 24.60% Objective-C 5.34% Swift 22.29%

react-native-ble-plx's Introduction

react-native-ble-plx

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!

GooglePlay AppStore


NPM


Recent Changes

0.4.0

  • Device ID properties were renamed as they are not UUIDs on Android (breaking change):
    • Device.uuid -> Device.id
    • Service.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 ./doc folder and now is generated by ESDoc.
  • Fixed state() invalid return type. Implemented state() and onStateChange() for Android.
  • Added optional parameter to onStateChange() function.
  • Fixed monitorCharacteristicForDevice() for Android when characteristic accepts indications only.
  • Updated AndroidManifest.xml configuration.

Documentation

Documentation can be found under ./doc folder.

Configuration & Installation

iOS:

  • Add react-native-ble-plx to a project as a dependency in package.json file. 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 install to fetch and install a library.
  • Open iOS project located in ./ios folder.
  • Move BleClient.xcodeproj located in .node_modules/react-native-ble-plx/ios using drag & drop to Libraries folder in your project.
  • In general settings of a target add libBleClient.a to Linked Frameworks and Libraries.
  • In Build Settings/Search Paths/Framework search paths add path: $(SRCROOT)/../node_modules/react-native-ble-plx/ios/BleClientManager/Carthage/Build/iOS.
  • In Build Settings/Build Options/Always Embed Swift Standard Libraries set to Yes.
  • In Build Phases click on top left button and add New 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
  • Minimal supported version of iOS is 8.0

Android:

  • Add react-native-ble-plx to a project as a dependency in package.json file. For example "react-native-ble-plx": "Polidea/react-native-ble-plx" will install latest version from Polidea's Github repository.
  • Execute npm install to fetch and install a library.
  • Open Android project located in ./android folder.
  • In settings.gradle add 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.gradle of app module 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.getPackages import 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.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"
        ...

react-native-ble-plx's People

Contributors

cierpliwy avatar konradrodzik avatar literator avatar jakublipinski avatar leo3linbeck avatar dariuszseweryn avatar

Watchers

Aiden Z avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.