Bluetooth in react-native

Leo Chen picture Leo Chen · Aug 27, 2015 · Viewed 53.4k times · Source

My project requires to receive&send bluetooth signal, and I am pretty new to react-native so which component I can use in react-native for bluetooth related functionality?

Answer

Jarek Potiuk picture Jarek Potiuk · Aug 27, 2015

Update (with disclaimer):

Since I gave the original answer, things have changed. In my company (Polidea) since we realised there is no very good library for React Native for BT we developed and fully open-sourced (permissive licence) our own solution. It's based on two RX-based Android and iOS native libraries and we wrote a common React Native wrapper around it so that you can use the same Javascript/RN interface but under the hood native iOS/Android specifics are handled in native code.

The library is here: https://github.com/Polidea/react-native-ble-plx

Disclaimer: I am a Principal Software Engineer and former CTO @Polidea - the company that created the library.

Original answer:

I don't think there is a built-in component for bluetooth access in RN.

If you want to use Bluetooth, you either need to write your own Obj-C API component (as described at https://facebook.github.io/react-native/docs/native-modules-ios.html#content ) or to use some 3rd party components that suit your needs where someone did it already. There are couple of those available (quick google search):

https://github.com/frostney/react-native-bluetooth-state

https://github.com/frostney/react-native-ibeacon

Not sure if they work well, but you can use them as starting point if you need other functionality.