Scanner
The Scanner API allows you to use the mobile device's camera to scan barcodes.
Anchor to scannerScanner
The scanner
API provides a capture
method that opens the mobile device's scanner to capture a barcode. It returns a Promise resolving to the scanned barcode data or an error.
- Anchor to capturecapture() => Promise<>required
ScannerApi
- capture
() => Promise<ScannerPayload>
export interface ScannerApi {
capture(): Promise<ScannerPayload>;
}
ScannerPayload
- data
string
export interface ScannerPayload {
data: string;
}
Was this section helpful?
Scanner
try {
const payload = await shopify.scanner.capture();
console.log('Scanner success', payload);
} catch (error) {
console.log('Scanner error', error);
}
examples
Scanner
try { const payload = await shopify.scanner.capture(); console.log('Scanner success', payload); } catch (error) { console.log('Scanner error', error); }