Deprecation warning
Please note that this is outdated documentation for an older release of the Scandit Barcode Scanner SDK.
We are deprecating the 5.x API on all platforms (except Linux). Release 5.19 in April 2021 will be our final. Applications running 5.x will continue to work, and we will continue to release critical bug fixes and security patches only, for one year. We encourage you to migrate to 6.x and take advantage of our latest / advanced features and improved performance.
You'll find the updated documentation at: Data Capture SDK Documentation for Cordova
To integrate the Scandit Barcode Scanner into your Cordova app, follow the simple steps below.
Get the Scandit Barcode Scanner SDK
Choose a plan (e.g., “Consumer Apps”, "Professional Apps", or “Enterprise/OEM” plan) at http://www.scandit.com/pricing and download the Scandit Barcode Scanner SDK for Android from your account.
Create a new project
If you do not have a Cordova project yet, you should create a new one.
Add the plugin to your project
Use the cordova CLI to add the plugin to your already existing project.
_Add the type definitions (TypeScript only)_
If you have a TypeScript project (e.g. Ionic, Angular, etc), you can import the type definition, just by making sure your TypeScript compiler knows about them. To make sure it does, you can either reference the type definition file at the beginning of the file you'll need them:
or by adding it to the included files in your tsconfig.json
file (preferred way):
As soon as the type definitions for the plugin are included, type checking and compilation should work as you'd expect and you can import as follows:
Instantiate and configure the barcode picker
The scanning process is managed by the BarcodePicker. Before instantiating the picker, you will have to set your Scandit Barcode Scanner license key. The key is available from your Scandit Barcode Scanner SDK account at http://account.scandit.com in the License Keys section. The barcode scanning is configured through an instance of scan settings that you pass to the BarcodePicker constructor.
Show the scan UI
Show the scanner to the user through show(success, manual, failure). You can pass it three callback functions, one for when a barcode is recognized, one for when a code was manually entered and one for when the scan process was canceled by the user.
For more information on the different ways to add the barcode picker to your view hierarchy, consult android-scanview-options.
Add callbacks to handle the scanning event
You now need to define the functions that are referenced in the show() call. All functions take one argument, the manual
Start the scanner
Start the actual scanning process to start the camera and look for codes.
Build and run the app
Compile your project. Attach a device and run the app on your desired plattform.