react-native-bluebird-barcode-scanner
v0.5.1
Published
React Native plugin for Bluebird android barcode scanners
Maintainers
Readme
react-native-bluebird-barcode-scanner
React Native plugin for Bluebird Android barcode scanners.
Talks to the scanner through the Bluebird bbapi broadcast Intent interface, so there is no
vendor SDK or .aar to install.
- Android only. The Bluebird scanner is Android hardware; autolinking skips iOS automatically, so you do not need to exclude this package by hand.
- Requires React Native >= 0.86 (New Architecture / TurboModule).
Installation
npm install react-native-bluebird-barcode-scannerThen rebuild the Android app. No pod install step is needed — the package declares no iOS
platform.
Usage
import {
open,
close,
getStatus,
setTrigger,
setParameter,
getParameter,
createEventEmitter,
CONSTANTS,
} from 'react-native-bluebird-barcode-scanner';
// Open the scanner, then arm the trigger.
await open();
await setTrigger(true);
// Listen for scans.
const emitter = createEventEmitter();
const subscription = emitter.addListener('decodingData', ({ data, symbology }) => {
console.log('scanned', data, symbology);
});
// Later.
subscription.remove();
await close();Actions
Every action sends a Bluebird Intent and resolves when the device replies. All of them reject with the Bluebird error code and message if the device reports a failure.
| Function | Description |
| --- | --- |
| open() | Opens the scanner. |
| close() | Closes the scanner. |
| getStatus() | Resolves with the current scanner status. |
| setTrigger(isActive: boolean) | Arms or disarms the scan trigger. |
| setParameter(param: BarcodeMode, value: string) | Sets a scanner parameter. |
| getParameter(param: BarcodeMode) | Reads a scanner parameter. |
Events
createEventEmitter() returns a typed NativeEventEmitter:
| Event | Fired when |
| --- | --- |
| decodingData | A barcode was scanned ({ data, symbology }). |
| requestSuccess | The device acknowledged a request. |
| requestFailed | The device rejected a request ({ errorCode, errorMessage }). |
| status | A getStatus() reply arrived ({ statusCode, status }). |
| open, close, setTrigger, setParameter, getParameter | Echo of the matching Intent. |
| event | Any unrecognised Intent. |
Constants
CONSTANTS is a plain JavaScript object — it is not read across the bridge, so it is safe to
use at module scope:
import { CONSTANTS } from 'react-native-bluebird-barcode-scanner';
CONSTANTS.BARCODE_MODE_TRIGGER; // number
CONSTANTS.SYMBOLOGY_QRCODE; // number
CONSTANTS.BBAPI_SUCCESS; // numberCompatibility
| Package | React Native |
| --- | --- |
| >= 0.5.0 | >= 0.86 |
| <= 0.4.0 | 0.70 (Old Architecture) |
Development
pnpm install # install the library's dependencies
pnpm run build # compile src/ -> dist/
pnpm test # lint + typecheck + unit tests
cd example
pnpm install
pnpm run android # build and run the example on a deviceThe example app links the library via "react-native-bluebird-barcode-scanner": "link:..", so
autolinking picks it up from node_modules and Metro resolves it through
@mgcrea/metro-plugin-linked-packages.
License
MIT
