Bluetooth in react-native

后端 未结 3 384
走了就别回头了
走了就别回头了 2020-12-12 17:15

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 functionalit

3条回答
  •  旧时难觅i
    2020-12-12 17:52

    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.

提交回复
热议问题