Class: BarcodeCaptureControl

BarcodeCaptureControl()

new BarcodeCaptureControl()

This BarCodeview is responsible for handling the corresponding plugin js to interact with the native BarCodeCaptureControl To set and get the properties, and to access the instance methods, corresponding JS methods are written under this class which are used by the end user in application script.

Methods

addBarCodeInitializationFailedListener(successCallback, errorCallback, barCodeInitializationFailedhandler)

This method would receive the events related to the bar code camera initialization
Parameters:
Name Type Description
successCallback function Default Success Call back function name when the event is registered
errorCallback function Default Error Call back function name
barCodeInitializationFailedhandler function a var to hold the bar code camera initialization failed event when it is actually raised
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back. errorCallback - error message would contain the appropriate error description.
Example
var barCodeControl =  kfxCordova.kfxUicontrols.createBarcodeCaptureControl();
function barCodeInitializationFailedhandler(){
  alert('barCodeCameraInitializationFailed');
}
barCodeControl.addBarCodeInitializationFailedListener(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));},barCodeInitializationFailedhandler);

addEventListener(successCallback, errorCallback, barcodeCallback)

To get the result back from the 'readBarcode' method's delegate, this method would be added as listener And the corresponding result from the delegate are returned in the success call back.
Parameters:
Name Type Description
successCallback function Default Success Call back function name, called when the event is registered successfully
errorCallback function Default Error Call back function name
barcodeCallback function function variable to hold the return value once the event is triggered
See:
  • The following is the format of the result. JSON object: { boundingBox = { bottomLeft = { x = "279.0027"; y = "238.6505"; }; bottomRight = { x = "285.7726"; y = "813.2451"; }; topLeft = { x = "348.4976"; y = "232.2123"; }; topRight = { x = "355.2836"; y = "832.2803"; }; }; dataFormat = "BASE_64"; direction = "TOP_DOWN"; imageID = "A1315979-F12F-4A0B-B9C7-3B12086EAB7C"; type = PDF417; value = "barcoderesultstring"; }
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException,Exception. barcodeCallback - will have the barcode data read from the barcode.
Example
var barCodeCaptureControl = kfxCordova.kfxUicontrols.createBarcodeCaptureControl();

barCodeCaptureControl.addEventListener(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));},function(jsonObject){alert(JSON.stringify(jsonObject));});

addView(successCallback, errorCallback, layoutObject)

Method to add the BarCodeReader view to the screen. This method is responsible for adding the view on the visible screen with the specified Layout values.
Parameters:
Name Type Description
successCallback function Default Success Call back function name
errorCallback function Default Error call back function name
layoutObject Object a 'Layout' object mentioning the Frame values for the BarCodeReader object. Refer to 'Layout' object for containing values.
Properties
Name Type Attributes Description
x Number <optional>
x position of the barcode capture control
y Number <optional>
y position of the barcode capture control
width Number <optional>
barcode capture control width
height Number <optional>
barcode capture control height
visibility Boolean <optional>
visibility of the barcode capture control
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back. errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException & Exception.
Example
var Layout = kfxCordova.getLayoutProperties();
Layout.x = 10;
Layout.y =10;
Layout.width= 300;
Layout.height = 400;
Layout.visibility = true; // By default visibility is 'true'

var barCodeCaptureControl = kfxCordova.kfxUicontrols.createBarcodeCaptureControl();

barCodeCaptureControl.addView(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));}, Layout);

getBarcodeCaptureControlparameters()

Method returning the BarCode properties that can be set by the user. Use this object as an input parameter to set the properties of the BarCodeCaptureControl.
Example
var barCodeControl =  kfxCordova.kfxUicontrols.createBarcodeCaptureControl();
 var barcodeParameters = barCodeControl.getBarcodeCaptureControlparameters();

getOptions(successCallback, errorCallback)

Method to get the properties of the native BarCodeCaptureControl class.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
See:
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - JSONObject representing BarcodeCaptureControl Options. JSONObject structure can also be known from getBarcodeCaptureControlparameters() method. errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException,JSONException & Exception.
Example
function mySuccessCB(options){
      alert(JSON.stringify(options));
      // Optionally you can get the properties and map to the application UI to show the user
}

var barCodeCaptureControl = kfxCordova.kfxUicontrols.createBarcodeCaptureControl();

barCodeCaptureControl.getOptions(mySuccessCB, function(error){alert(JSON.stringify(error));});

readBarcode(successCallback, errorCallback)

This call returns immediately and starts asynchronously searching for a barcode with the current camera and barcode parameters. The search will continue indefinitely until a barcode is found, allowing time for the device to further stabilize and focus if necessary. Once a barcode is positively read, the event listener "addEventListener" will be invoked and the results are in the event listener success call back. License Required: This is a licensed method. You cannot use this method until you have set a valid SDK license.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS The bar code was successfully read. errorCallback - KMC_EV_LICENSING The bar code was not set successfully read, and returned the licensing error code..Possible error objects are KmcRuntimeException,JSONException & Exception.
Example
var barCodeCaptureControl = kfxCordova.kfxUicontrols.createBarcodeCaptureControl();
barCodeCaptureControl.readBarcode(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));});

removeBarCodeInitializationFailedListener(successCallback, errorCallback)

The method would remove the listener and would not receive any bar code camera initialization failed events
Parameters:
Name Type Description
successCallback function Default Success Call back function name
errorCallback function Default Error Call back function name
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException,Exception.
Example
var barCodeControl =  kfxCordova.kfxUicontrols.createBarcodeCaptureControl();
barCodeControl.removeBarCodeInitializationFailedListener(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));});

removeEventListener(successCallback, errorCallback)

The method would remove the listener to the delegate call back of the readbarcode method. After removing the listener, there will not be any call backs from native from the 'readbarcode' delegate methods though it is being called at native.
Parameters:
Name Type Description
successCallback function Default Success Call back function name
errorCallback function Default Error Call back function name
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException,Exception.
Example
// create your bar code object
var barCodeCaptureControl = kfxCordova.kfxUicontrols.createBarcodeCaptureControl();

// read your bar code..

//to remove the barcodereader listener

barCodeCaptureControl.removeEventListener(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));});

removeView(successCallback, errorCallback)

Method to remove the BarCodeReader view off the screen. This method is responsible for removing and making it nil.
Parameters:
Name Type Description
successCallback function Default Success Call back function name
errorCallback function Default Error call back function name
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back errorCallback - error message would contain the appropriate error description.Possible error objects are KmcRuntimeException,Exception.
Example
var barCodeCaptureControl = kfxCordova.kfxUicontrols.createBarcodeCaptureControl();
barCodeCaptureControl.removeView(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));});

setOptions(successCallback, errorCallback, properties)

Method to set the properties of the native BarCodeCaptureControl class.
Parameters:
Name Type Description
successCallback function Default Success call back function name
errorCallback function Default Error call back function name
properties Object a 'barcodeCaptureControlParams' variable containing the properties to be set to the BarCodeCaptureControl
Properties
Name Type Attributes Description
searchDirection Array <optional>
Searching multiple directions slows down the speed of barcode recognition. If you expect barcodes to only be oriented in certain directions, you should specify only those directions. By default, all directions will be searched, represented by the array ["HORIZONTAL", "VERTICAL"].Acceptable values are: "HORIZONTAL", "VERTICAL", and "ALL".
symbologies Array <optional>
Searching for multiple symbologies slows down the speed of barcode recognition. You should only specify the symbologies that you are interested in reading. The set of selected symbologies is empty by default. Acceptable values are: "CODE39", "PDF417", "QR", "DATAMATRIX", "CODE128", "CODE25", "EAN", "UPC", "CODABAR", "AZTEC" and "CODE93".
guidingLine String <optional>
The guiding line is a visual aid for aligning barcodes within the preview. A guiding line is rendered as a straight line splitting the preview into two equal parts. The intention is for the line to cross through all the bars of a barcode, like the laser of a linear scanner. The guiding line is turned off by default. Acceptable values are: "OFF", "LANDSCAPE", and "PORTRAIT".
See:
  • see BarcodeCaptureControl#getBarcodeCaptureControlparameters for detailed description of parameters what we have to pass.
  • Check the 'errorCallback' method for any failures in case of unexpected behaviour of the method. Generally the error call back would return a JSON object with ErrorMsg & ErrorDesc' giving the description of the error.
Returns:
The return value is captured in the 'successCallback' for a successful operation, and might return in 'errorCallback' for an incomplete/invalid operation. Returns the following values in the corresponding functions successCallback - KMC_SUCCESS success call back errorCallback - error message would contain the appropriate error description.Possible error objects are Wrong Parameters, KmcRuntimeException & Exception.
Example
var barCodeCaptureControl = kfxCordova.kfxUicontrols.createBarcodeCaptureControl();

var  barcodeCaptureControlParams =  barCodeCaptureControl.getBarcodeCaptureControlparameters();
barcodeCaptureControlParams.searchDirection = ["VERTICAL"];
barcodeCaptureControlParams.symbologies = ["CODE39", "PDF147"];
barcodeCaptureControlParams.guidingLine = "LANDSCAPE";

barCodeCaptureControl.setOptions(function(success){alert(JSON.stringify(success));},function(error){alert(JSON.stringify(error));},barcodeCaptureControlParams);