Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support barcode scanning via devices connected over Bluetooth #7

Open
Bluesir9 opened this issue Jun 14, 2021 · 1 comment
Open

Support barcode scanning via devices connected over Bluetooth #7

Bluesir9 opened this issue Jun 14, 2021 · 1 comment

Comments

@Bluesir9
Copy link
Collaborator

Based on discussion with @jmiranda, this would be a 2 part functionality:

  1. Get data from devices connected over Bluetooth.
  2. Resolve data received over Bluetooth.

Getting data from devices connected over Bluetooth

There are 2 types of workflows that need to be supported as part of this

  1. Barcode scanning devices that communicate over Bluetooth directly.
  2. Barcode scanning devices that communicate via a custom protocol.

Barcode scanning devices that communicate over Bluetooth directly

Based on the demo provided by @jmiranda, these devices are first connected to the smart phone over Bluetooth and post that, whenever they detect any sort of barcode, they pass along that data to the smart phone and that data gets "pasted" into any text field that was in focus at the time.

Pretty bare bones setup. There must be some way to intercept that "pasting" action so that we can intercept that data and do something with it.

Barcode scanning devices that communicate via a custom protocol.

Let's look at Zebra devices for an example. They have their own SDKs and they also have APIs that rely on Android intents to communicate scanned data. The latter would obviously not work for iOS devices. So in order to support these devices, we will have to use their SDKs/APIs.

Resolve data received over Bluetooth

Once data has been received over Bluetooth, we need to figure out if it's relevant to us and then do something with it.

For now we are going to assume that the scanned data is going to point to a product "id" and upon scanning we are immediately going to resolve it as such. And if the scanned data was successfully resolved as a product, we will open the product details page for the same. Doesn't matter where the user was earlier, if a product was scanned, we will immediately take them to the respective product details page.

With bar code scanning, this is where we are going to try to get before considering further use cases.

@Bluesir9
Copy link
Collaborator Author

@jmiranda I have hit a blockade with bluetooth communication in relation to Expo.

I was looking at this library to capture data sent over Bluetooth only to learn that Expo doesn't support addition of any "native modules".

Because Expo essentially has its own runtime that we are running our app inside of, we can only run code that doesn't require making any changes that are specific to the native side of things i.e. Android or iOS environment. If we wish to make such changes, we would have to make them in the Expo runtime itself, and as such that isn't supported at the moment.

And because Bluetooth access requires adding custom code for Android and iOS environments, and Expo does not have first class support for that usecase in their own runtime, we cannot add the library I mentioned above to our app without ejecting from Expo.

They have been working on a tool called EAS build that would allow one to make changes to their runtime but at the moment it's available as a paid feature only. You can read more about it here

So bottom line, if we wish to use bluetooth libraries in our codebase, we will have to eject the app from Expo and go via the bare bones React Native route. It is what the folks at Expo recommend as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant