How to make the React Native app listen to HID Bluetooth device (QR code scanner)

339 Views Asked by At

Basically I have a React Native application which has one of the screens, where I have to listen to the external Bluetooth QR codes scanner which works as a HID device (!) which is already connected to the mobile device, not to the application itself.

Am I right that:

  1. I even shouldn't establish the bluetooth usage permissions in the app
  2. Since the QR code scanner works as HID device, I simply have to listen to the external data input once I entered this screen, and stop listening when I leave this screen?

If yes - then how? Thank you in advance

1

There are 1 best solutions below

0
Risto On

HID devices, like cable-bound devices, are already processed by the OS kernel and the corresponding messages are not even passed through to the application.

However, your application can access the resulting events (key, mouse or similar) and use them to design its function.

Broken down to an application example with a text field and a QR code that is to be read into this text field via the HID QR code scanner, this would mean:

  • Call up the corresponding dialogue in your application
  • Set the input focus on the corresponding input field
  • Read the QR code via scanner