Files
lst_v3/lstMobile/src/lib/ZebraScanner.ts

44 lines
790 B
TypeScript

import {
type EmitterSubscription,
NativeEventEmitter,
NativeModules,
} from "react-native";
const { ZebraScanner } = NativeModules;
const scannerEmitter = new NativeEventEmitter(ZebraScanner);
export type ZebraScanResult = {
data: string;
labelType?: string;
source?: string;
timestamp: number;
};
export const zebraScanner = {
startListening() {
ZebraScanner.startListening();
},
stopListening() {
ZebraScanner.stopListening();
},
triggerScan() {
ZebraScanner.triggerScan();
},
ensureProfile() {
ZebraScanner.ensureProfile();
},
addScanListener(
callback: (scan: ZebraScanResult) => void,
): EmitterSubscription {
return scannerEmitter.addListener("barcodeScanned", callback);
},
disableScannerInput() {
ZebraScanner.disableScannerInput();
},
};