Scan API: Socket Mobile Scanning

Supported in:

Kiosk Pro Enterprise

Added in 9.5.4

Scan barcodes and QR codes using a Socket Mobile S800 scanner. This JavaScript API can check the connection status of the scanner and battery level, as well as return data from scanned barcodes.

Functions

Callbacks

Related Settings


Requirements

  • Access JavaScript API
    • By Import - recommended, works both online & offline, requires inclusion of kiosk_functions.js prior to any of the following calls.
    • By Injection - only works offline, may not be available 'onload'.
  • Barcode & QR Code Scanning > Socket Mobile Scanning = On


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

Download Sample Code


kp_SocketScannerAPI_requestStateOfSupporting

This function determines whether Socket Mobile scanning is enabled in Kiosk Pro's settings.

Format
kp_SocketScannerAPI_requestStateOfSupporting(callback);
		
Parameters callback = [string] name of callback function which will be called with the following signature: callback(supported).
Callback format
callback(supported)
		
Callback return values

supported = [integer] returns whether the Socket Mobile scanner setting is enabled. Possible values are:

  • 0 = Not enabled
  • 1 = Enabled


kp_SocketScannerAPI_requestBatteryLevel

This function checks the battery level of the Socket Mobile scanner.

Format
kp_SocketScannerAPI_requestBatteryLevel();
		
Parameters callback = [string] name of callback function which will be called with the following signature: callback(levelInPercent).
Callback format
callback(levelInPercent)
		
Callback return values

levelInPercent = [integer] returns the battery level of the Socket Mobile scanner as a percentage. Possible values are:

  • -1 = Undefined, Socket Mobile scanner is likely not connected
  • 0-100 = Battery level


kp_SocketScannerAPI_didConnectToDevice

This callback triggers when the Socket Mobile scanner connects to Kiosk Pro.

Format
kp_SocketScannerAPI_didConnectToDevice(device);
		
Return values

device - [associative array] key/value pairs containing information about the Socket Mobile scanner. Possible values are:

  • friendlyName - [string] name for identifying the scanner.
  • deviceType - [integer] scanner model as a SKT Capture device type numeric value, representing  a combination of product type and interface. Returned as a large Objective-C enumeration.
  • deviceTypeFriendlyName - [string] model name of scanner.
  • guid - [string] unique identifier of device. Due to iOS privacy restrictions, this value changes every time the scanner is connected.


kp_SocketScannerAPI_didDisconnectFromDevice

This callback triggers when the Socket Mobile scanner disconnects from Kiosk Pro.

Format
kp_SocketScannerAPI_didDisconnectFromDevice(device);
		
Return values

device - [associative array] key/value pairs containing information about the Socket Mobile scanner. Possible values are:

  • friendlyName - [string] name for identifying the scanner.
  • deviceType - [integer] scanner model as a SKT Capture device type numeric value, representing  a combination of product type and interface. Returned as a large Objective-C enumeration.
  • deviceTypeFriendlyName - [string] model name of scanner.
  • guid -[string] unique identifier of device. Due to iOS privacy restrictions, this value changes every time the scanner is connected.


kp_SocketScannerAPI_didReceiveDecodedDataFromDevice

This callback is triggered when the app finishes the scanning process successfully.

If 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

decodedData - [associative array] key/value pairs containing information about the scanned data. Possible values are:

  • DataSourceID - [integer] decoded data source ID.
  • DataSourceIDFriendlyName - [string] readable decoded data source ID.
  • DataSourceName - [string] data source name.
  • DecodedData - [string] data returned from the barcode. Each byte transforms to string: @"%02X", (unsigned char)bytes[i].
  • StringFromDecodedData - [string] data returned from the barcode. This may not be returned if the data in the barcode is not UTF8 encoded.

device - [associative array] key/value pairs containing information about the Socket Mobile scanner. Possible values are:

  • friendlyName - [string] name for identifying the scanner.
  • deviceType - [integer] scanner model as a SKT Capture device type numeric value, representing  a combination of product type and interface. Returned as a large Objective-C enumeration.
  • deviceTypeFriendlyName - [string] model name of scanner
  • guid - [string] unique identifier of device. Due to iOS privacy restrictions, this value changes every time the scanner is connected.


kp_SocketScannerAPI_didReceiveError

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

error - [associative array] key/value pairs containing information about the scanned data. Possible values are:

  • domain - [string] where the error occurred
  • code - [integer] an identifier for the error
  • description - [string] a brief description of error
  • failureReason - [string] a reason for the error (optional, may return as empty)
  • recoverySuggestion - [string] a suggested solution (optional, may return as empty)
  • debugDescription - [string] a detailed description of the error (optional, may return as empty)

Still stuck? How can we help? How can we help?