Newer Version Available
Understand BarcodeScanner Modern and Legacy APIs
Legacy APIs and Modern APIs
We use the terms legacy APIs and modern APIs here. Let’s clarify what they mean.
- Legacy APIs refer to the functions beginCapture(), resumeCapture(), and endCapture()
- Modern APIs refer to the functions scan() and dismiss()
The legacy APIs are supported, but will be retired in a future release–the modern APIs replace them fully. The legacy APIs support single scanning and continuous scanning modes, but not bulk scanning or multi-scanning.
The modern APIs are, as you’ve probably guessed, a newer addition to BarcodeScanner. They were created to simplify the development experience, and they support all scanning modes, including bulk scanning and multi-scanning.
The following table summarizes the relationships of the legacy APIs to the modern APIs replacing them:
| Legacy API | Modern API | Notes |
| beginCapture() | scan() | scan() replaces both beginCapture() and resumeCapture(). |
| resumeCapture() | scan() | |
| endCapture() | dismiss() |
Practical Differences Between scan() and beginCapture()
For the most part, the behavior of the modern APIs is identical to their legacy counterparts. One notable difference is how the returned promise is resolved in scan(), compared to beginCapture().
In beginCapture(), the returned Promise resolves to a single result. In scan(), the returned Promise resolves to an array of results. Because bulk scanning and multi-scanning process multiple barcodes simultaneously, only the modern scan() API supports them.