Scandit's Barcode Link SDK allows you to scan barcodes on your mobile device and automatically send them to another device.
$ npm i @scandit/web-barcode-link
import { BarcodeLink, BarcodeLinkMode } from "scandit-web-barcode-link";
const barcodeLink = BarcodeLink.forLicenseKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --")
.setBarcodeLinkMode(BarcodeLinkMode.ContinuousListBuilding)
.setSymbologies({ ean13Upca: { enabled: true } })
.addListener({
onCapture: (barcodes) => console.log("Captured:", barcodes}),
});
await barcodeLink.initialize();
Static method for creating a new BarcodeLink instance with your license key. This is the only way to construct a new BarcodeLink instance.
const barcodeLink = BarcodeLink.forLicenseKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --");
Specify the scanning mode to enable:
Value | Description |
---|---|
SingleScanning | Send one barcode and close the session |
ContinuousScanning | Send barcodes in realtime and close the session when you want |
SingleListBuilding | Send a list of barcodes and close the session |
ContinuousListBuilding | Send lists of barcodes in realtime and close the session when you want |
import { BarcodeLinkMode } from "@scandit/web-barcode-link";
barcodeLink.setBarcodeLinkMode(BarcodeLinkMode.ContinuousListBuilding);
Specify which symbologies to enable, and optional settings for each symbology:
barcodeLink.setSymbologies({
ean13Upca: { enabled: true },
});
Specify a regex that will be used to ignore barcodes that do not match the regular expression:
barcodeLink.setBarcodeRegexValidation(/\d+/);
Add a listener to listen to specific events:
barcodeLink.addListener({
onCancel?() {}
onCapture?(barcodes) {}
onDeviceConnected?() {} // Only triggered in a uiless flow
onDeviceDisconnected?() {} // Only triggered in a uiless flow
});
Remove a listener:
barcodeLink.removeListener(listener);
Start the barcode link workflow
Optionally accepts a flow
parameter, that can be used to enable different workflows.
Opens a popup that will guide you through the scanning process. This is the default flow.
await barcodeLink.initialize();
// Equivalent
await barcodeLink.initialize(new BarcodeLinkUiFlow());