react-native-bluetooth-android
reactnative bluetooth module for android paltform
Last updated a month ago by watson233 .
ISC · Original npm · Tarball · package.json
$ cnpm install react-native-bluetooth-android 
SYNC missed versions from official npm registry.

react-native-bluetooth-android

ReactNative 蓝牙库,适用于安卓平台

快速开始

$ npm install react-native-bluetooth-android --save

使用 yarn

$ yarn add react-native-bluetooth-android

自动链接

$ react-native link react-native-bluetooth-android

手动安装

Android

  1. 打开 android/app/src/main/java/[...]/MainActivity.java
  • import com.reactlibrary.RNBluetoothPackage; to the imports at the top of the file
  • Add new RNBluetoothPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-react-native-bluetooth'
    project(':react-native-react-native-bluetooth').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-react-native-bluetooth/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-react-native-bluetooth')
    

使用

import * as RNBluetooth from 'react-native-bluetooth-android';


API 列表

openBluetoothAdapter

使用async, await

try {
	const res = await openBluetoothAdapter()
	console.log(res)
} catch (e) {
	console.error(e)
}

使用promise

openBluetoothAdapter().then(result => {
	console.log(res)
}).catch(e => {
	console.error(e)
})

closeBluetoothAdapter

startDevicesDiscovery

stopDevicesDiscovery

listDevices

createConnection

closeConnection

writeBuffer

onDataReceived

onDeviceFound

onConnectionLost

Current Tags

  • 1.0.2                                ...           latest (a month ago)

3 Versions

  • 1.0.2                                ...           a month ago
  • 1.0.1                                ...           a month ago
  • 1.0.0                                ...           a month ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 3
Last Month 35
Dependencies (1)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |