@castrintt/castro-barcode-reader
v2.0.0
Published
React Native Honeywell Barcode Reader with notification control
Maintainers
Readme
@castrintt/castro-barcode-reader
React Native library for Honeywell barcode scanners with enhanced notification control.
Fork of react-native-honeywell-barcode-reader with additional features.
✨ Features
- ✅ Read barcodes from Honeywell integrated scanners
- ✅ NEW: Disable/enable scanner notifications (sound & vibration)
- ✅ NEW: Generic property setters for advanced configuration
- ✅ TypeScript support
- ✅ Compatible with modern React Native versions
📱 Supported Devices
- Honeywell EDA60K
- Honeywell EDA61K
- Honeywell CT50/CT60
- Other Honeywell devices with integrated scanners
🚀 Installation
npm install @castrintt/castro-barcode-readeror
yarn add @castrintt/castro-barcode-readerAndroid Configuration
Add to android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="com.honeywell.decode.permission.DECODE"/>📖 Usage
Basic Example
import HoneywellBarcodeReader from '@castrintt/castro-barcode-reader';
// Check compatibility
if (HoneywellBarcodeReader.isCompatible) {
console.log('Device is compatible!');
}
// Start reader
const claimed = await HoneywellBarcodeReader.startReader();
if (claimed) {
console.log('Scanner claimed successfully');
// Disable notifications
await HoneywellBarcodeReader.disableScannerNotifications();
}
// Listen for scans
HoneywellBarcodeReader.onBarcodeReadSuccess((event) => {
console.log('Barcode:', event.data);
});
HoneywellBarcodeReader.onBarcodeReadFail(() => {
console.log('Scan failed');
});
// Stop reader when done
await HoneywellBarcodeReader.stopReader();
HoneywellBarcodeReader.offBarcodeReadSuccess();
HoneywellBarcodeReader.offBarcodeReadFail();React Hook Example
import { useEffect } from 'react';
import HoneywellBarcodeReader from '@castrintt/castro-barcode-reader';
function useBarcodeScanner(onScan: (data: string) => void) {
useEffect(() => {
if (!HoneywellBarcodeReader.isCompatible) return;
const startScanner = async () => {
const claimed = await HoneywellBarcodeReader.startReader();
if (claimed) {
await HoneywellBarcodeReader.disableScannerNotifications();
HoneywellBarcodeReader.onBarcodeReadSuccess((event) => {
onScan(event.data);
});
}
};
startScanner();
return () => {
HoneywellBarcodeReader.stopReader();
HoneywellBarcodeReader.offBarcodeReadSuccess();
HoneywellBarcodeReader.offBarcodeReadFail();
};
}, [onScan]);
}🎯 API Reference
Methods
isCompatible: boolean
Check if the device has a Honeywell scanner.
startReader(): Promise<boolean>
Start the barcode reader. Returns true if successfully claimed.
stopReader(): Promise<void>
Stop the barcode reader and release resources.
disableScannerNotifications(): Promise<boolean> 🆕
Disable sound and vibration notifications.
enableScannerNotifications(): Promise<boolean> 🆕
Re-enable sound and vibration notifications.
setReaderProperty(propName: string, value: boolean): Promise<boolean> 🆕
Set a boolean property on the scanner.
setReaderPropertyInt(propName: string, value: number): Promise<boolean> 🆕
Set an integer property on the scanner.
setReaderPropertyString(propName: string, value: string): Promise<boolean> 🆕
Set a string property on the scanner.
onBarcodeReadSuccess(handler: (event: { data: string }) => void): void
Register a callback for successful barcode reads.
onBarcodeReadFail(handler: () => void): void
Register a callback for failed barcode reads.
offBarcodeReadSuccess(): void
Remove the barcode read success callback.
offBarcodeReadFail(): void
Remove the barcode read fail callback.
🔧 Advanced Configuration
// Custom property examples
await HoneywellBarcodeReader.setReaderProperty(
'PROPERTY_TRIGGER_CONTROL_MODE',
'TRIGGER_CONTROL_MODE_AUTO_CONTROL'
);
await HoneywellBarcodeReader.setReaderPropertyInt(
'PROPERTY_DECODE_TIMEOUT',
5000
);📝 License
MIT
🙏 Credits
Based on duytq94/react-native-honeywell-barcode-reader
🤝 Contributing
Contributions are welcome! Please open an issue or submit a pull request.
📧 Support
For issues and questions, please use the GitHub Issues page.
├── .gitignore ✅
└── .npmignore ✅ (novo)
