Bug(s) or Feature(s)

API Overview

Not all functionality is available across both Android and IOS (for Apple MFi related annoying details); for that reason all calls will respond with a Promise which will throw an implementation error if attempting to call on IOS (which is completely different from previous versions where IOS would just reject the Promise). You'll probably want to either:

  • Wrap your functionality in Platform.IOS
  • Duplicate your code with Component.[android|ios].js
  • or handle the the Error appropriately

RN Bluetooth Classic

RNBluetoothClassic is the primary point of access for all Adapter/External Accessory related calls.

import RNBluetoothClassic from 'react-native-bluetooth-classic';

Provides access to the following:

isBluetoothAvailableDetermine whether device has Bluetooth as a feature
isBluetoothEnabledDetermine whether device has enabled Bluetooth
getBondedDevicesList currently paired/bonded devices
getConnectedDevicesList currently connected devices
getConnectedDeviceRetrieves a connected BluetoothDevice
onBluetoothEnabledProvide a listener for Bluetooth enabled events
onBluetoothDisabledProvide a listener for Bluetooth disabled events
onStateChangedProvides a listener for Bluetooth state change events
onDeviceConnectedProvide a listener for when a device connection is initiated
onDeviceDisconnectedProvide a listener for when a device connection has dropped
onErrorProvide a listener for any generic errors from Adapter or Device
startDiscoveryInitiate the discovery process
cancelDiscoveryCancel the discovery process
pairDeviceRequest to pair with a device
unpairDeviceRequest to unapir a device
acceptAttempt to accept a device connection
cancelAcceptCancels accepting a device connection
requestBluetoothEnabledRequest that the system enable Bluetooth
setBluetoothAdapterNameAttempt to rename the BluetoothAdapter
openBluetoothSettingsOpens Android's Bluetooth Settings programmatically

The term connection refers to an active socket; not just being paired/bonded. Please be aware of this prior to opening any issues.

Bluetooth Device

BluetoothDevice(s) are available from a number of RNBluetoothClassic functions. These are the functions available while working with BluetoothDevice(s):

isConnectedDetermine whether the device has an active connection
connectAttempt connection to the device
disconnectAttempt to disconnect from the device
availableWhether and how much data is available for read
clearClear the current read buffer
readRead data from the device (if available)
writeWrite to the device
onDataReceivedAdd a listener to handle read events

onDataReceived and read shouldn't really be used at the same time as you could end up with half filled data or random errors. I suggest sticking to one method setInterval or onRead in order to continuously get data

A number of the previous functions are also available directly from RNBluetoothClassic. But in most cases it's wise to use the BluetoothDevice returned from one of the prior functions in order to manage directly