API: Return Data from Socket Mobile Scanners & RFID/NFC Readers
Scan barcodes and QR codes using a Socket Mobile S800 scanner or RFID and NFC cards, key fobs, tags, and labels using a SocketScan S550 contactless reader. This JavaScript API can return data, as well as check the connection status and battery level of the Socket Mobile devices.
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
- One of the following turned On:
- Peripherals & Integrations > Card Readers > Enable Socket Mobile NFC Reader = On
- Peripherals & Integrations > 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. Scanner must be set to "Application Mode". For more information about the Socket Mobile S800 scanner, click here.
- Socket Mobile SocketScan S550 RFID reader. For more information about the SocketScan S550 RFID reader, click here.
Triggers via API Functions
Check if Device is Enabled
This function checks whether a Socket Mobile device 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 device.
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 Device is Connected
This callback triggers when the Socket Mobile device connects to Kiosk Pro.
Format | kp_SocketScannerAPI_didConnectToDevice(device); |
---|---|
Return values |
|
When Device is Disconnected
This callback triggers when the Socket Mobile device disconnects from Kiosk Pro.
Format | kp_SocketScannerAPI_didDisconnectFromDevice(device); |
---|---|
Return values |
|
When Data is Returned
This callback is triggered when the app returns data 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 support for Socket Mobile S800 scanner in version 9.5.4. Added support for Socket Mobile SocketScan S550 NFC reader in version 10.1.