API: Scan Using Socket Mobile Scanners
Scan barcodes and QR codes using a Socket Mobile S800 scanner. This JavaScript API can return data from scanned barcodes, as well as check the connection status of the scanner and battery level.
In this article
Requirements
- Integration of our JavaScript API into your webpage
- Sample code to run within the app and download for integration into your own project is available here.
- Best practices for working with the JavaScript API are available here.
- App Settings
- JavaScript > Access JavaScript API > By Import
- Other Peripherals & Integrations > External Barcode & QR Code Scanners > Enable Socket Mobile Scanner = On
- iOS/iPadOS Permissions
- Bluetooth - more on enabling specific iOS/iPadOS permissions here
- Physical Hardware
- Socket Mobile S800 scanner. For more information about the Socket Mobile S800 scanner, click here.
Triggers via API Functions
Check if Scanning is Enabled
This function checks whether Socket Mobile scanning is enabled in Kiosk Pro's settings.
Format | kp_SocketScannerAPI_requestStateOfSupporting(callback); |
Parameters | callback - [string] the name of the callback to be triggered after the function has been executed |
Callback format | callback(supported); |
Callback return values |
|
Check Battery Level
This function checks the battery level of the Socket Mobile scanner.
Format | kp_SocketScannerAPI_requestBatteryLevel(); |
---|---|
Parameters | callback - [string] the name of the callback to be triggered after the function has been executed |
Callback format | callback(levelInPercent) |
Callback return values |
|
Notifications via API Callbacks
When Scanner is Connected
This callback triggers when the Socket Mobile scanner connects to Kiosk Pro.
Format | kp_SocketScannerAPI_didConnectToDevice(device); |
---|---|
Return values |
|
When Scanner is Disconnected
This callback triggers when the Socket Mobile scanner disconnects from Kiosk Pro.
Format | kp_SocketScannerAPI_didDisconnectFromDevice(device); |
---|---|
Return values |
|
When a Scan is Returned
This callback is triggered when the app finishes the scanning process successfully.
If the source image contains a valid code but this code does not match a supported type of code (as defined in Kiosk Pro settings) or if the source image does not contain a valid code, then this callback will not be triggered and the image will be ignored.
Format | kp_SocketScannerAPI_didReceiveDecodedDataFromDevice(decodedData, device); |
---|---|
Return values |
|
When an Error is Returned
This callback is triggered when the camera is unable to recognize any images as a valid barcode for a period of 15 seconds.
Format | kp_SocketScannerAPI_didReceiveError(error); |
---|---|
Return values |
|
Sample Code
- This sample code relies on the JavaScript APIs built into Kiosk Pro and will not run successfully in other browsers or within our in-app help interface.
- To run sample code, set the app's homepage to https://kioskgroup.com/socket-mobile-api
- To download a .zip of sample code, click here.
Change Log
- Added in version 9.5.4.