Develop Secure Code
BarcodeScanner Constants
BarcodeScanner Data Types
getBarcodeScanner()
isAvailable()
scan(options)
dismiss()
beginCapture(options) (Legacy)
resumeCapture() (Legacy)
endCapture() (Legacy)
endCapture() (Legacy)Use this function to end a scanning session, close the mobile OS scanning interface, and dispose of resources.
We recommend using the modern scan() and dismiss() APIs in your LWC’s scanning code to streamline your development experience. The legacy APIs beginCapture(), resumeCapture(), and endCapture() are still available, but will be retired in a future release.
Note
1import { getBarcodeScanner } from 'lightning/mobileCapabilities';
2endCapture(): voidNone.
None.
1myScanner
2 .beginCapture(scanningOptions)
3 .then((result) => {
4 console.log(result);
5 this.scannedBarcode = result.value;
6 })
7 .catch((error) => {
8 console.error(error);
9 })
10 .finally(() => {
11 // Handle final cleanup
12 myScanner.endCapture();
13 });After calling endCapture(), you can call beginCapture() on an existing or new BarcodeScanner instance to start a new scanning session.
See Also