@scandit/web-barcode-link
v0.2.0
Published
The Scandit Web Barcode Link package
Downloads
7
Readme
@scandit/web-barcode-link
Scandit's Barcode Link SDK allows you to scan barcodes on your mobile device and automatically send them to another device.
Installation
$ npm i @scandit/web-barcode-link
Getting started
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();
API
BarcodeLink
forLicenseKey
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 --");
setBarcodeLinkMode
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);
setSymbologies
Specify which symbologies to enable, and optional settings for each symbology:
barcodeLink.setSymbologies({
ean13Upca: { enabled: true },
});
setBarcodeRegexValidation (optional)
Specify a regex that will be used to ignore barcodes that do not match the regular expression:
barcodeLink.setBarcodeRegexValidation(/\d+/);
addListener
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
});
removeListener
Remove a listener:
barcodeLink.removeListener(listener);
initialize
Start the barcode link workflow
Optionally accepts a flow
parameter, that can be used to enable different workflows.
BarcodeLinkUiFlow
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());