Necessitates Proper Modularity

    @datalogic/cordova-plugin-datalogic

    0.4.1 • Public • Published

    Datalogic Cordova Plugin

    Library that exposes the Datalogic Android (Java) SDK as a Cordova plugin. It lets you receive barcode data from the scanner, as well as configure various scanner and device settings. It is available as a npm package for easy consumption here: @datalogic/cordova-plugin-datalogic.

    Installation

    You can install the plugin from the npm registry as follows:

    npm i @datalogic/cordova-plugin-datalogic

    ...or use the following Cordova CLI command:

    cordova plugin add @datalogic/cordova-plugin-datalogic

    or, if you are using ionic, this ionic command:

    ionic cordova plugin add @datalogic/cordova-plugin-datalogic

    or, if you are using PhoneGap CLI, this phonegap command:

    phonegap plugin add @datalogic/cordova-plugin-datalogic
    
    ## Publish new version
    
    Install and use the [np tool](https://github.com/sindresorhus/np):
    
    ``` bash
    npm install --global np
    np

    Sample apps

    Several Ionic sample applications are provided to demonstrate using the plugin. You can find them here.

    API Reference

    All functions are asynchronous. All functions will, at a minimum, include successCallback and errorCallback parameters, both of which are callback functions.

    • successCallback will be called in normal cases, and will return an appropriate JSON object.

    • errorCallback will be called when there was an error, and will return a single error string.

    Namespaces

    Namespace Description
    barcodeManager receive barcode data
    autoScanTrigger work the the autoscan features
    keyboardManager set usable device triggers
    ledManager control device LEDs
    scannerProperties define availabled symbologies

    barcodeManager


    Function Description
    addReadListener Register to recieve barcode data on each scan.
    pressTrigger Simulate a trigger button press.
    releaseTrigger Simulate a trigger button release.

    .addReadListener(successCallback, errorCallback): Object

    Register to recieve barcode data on each scan. successCallback will be called every time a barcode is successfully scanned. Therefore, you will typically only need to call barcodeManager.addReadListener() once in your application.

    Response
    {
       "barcodeData": "EUG2997",
       "barcodeType": "CODE128"
    }
    Example
    declare let barcodeManager : any;
    ...
    barcodeManager.addReadListner(
       (data) => {
         parsedData = JSON.parse(data);
         alert(parsedData.barcodeData + ", " + parsedData.barcodeType);
       },
       (err)=>{ alert(err); }
    );

    .pressTrigger(successCallback, errorCallback): Object

    Call this method to simulate a trigger button press. The method does not always immediately start a capture; instead it behaves like pressing a physical scan button.

    Response

    string with success message

    Example
    barcodeManager.pressTrigger(
      (data) => { alert(data); },
      (err) => { alert(err);}
    );

    .releaseTrigger(successCallback, errorCallback): Object

    Call this method to simulate a release of a trigger button. The method does not always immediately stop a capture; instead it behaves like releasing a physical scan button.

    Response

    string with success message

    Example
    barcodeManager.releaseTrigger(
      (data) => { alert(data); },
      (err) => { alert(err);}
    );

    autoScanTrigger


    Function Description
    isAvailable Determine if the auto scan feature is available on this device.
    getSupportedRanges Get the supported ranges of the autoscan feature.
    getCurrentRange Get the current range of the autoscan feature.
    setCurrentRange Set the current range of the autoscan feature.

    .isAvailable(successCallback, errorCallback): Object

    Determine if the auto scan feature is available on this device.

    Response
    • available : boolean - indicates if autoscan is supported or not on this device.
    { "available": true }
    Example
    declare let autoScanTrigger : any;
    isAvailable : boolean = false;
    ...
    autoScanTrigger.isAvailable(
      (data) => {
        this.isAvailable = JSON.parse(data).available;
        alert(this.isAvailable);
      },
      (err) => { alert(err); }
    );

    .getSupportedRanges(successCallback, errorCallback): Object

    Get the supported ranges of the autoscan feature.

    Response

    supportedRanges : array - provides array of ranges device supports. The array will be empty if device deos not support autoscan. Each object in the array contains:

    • id : integer - unique value for a step in the supported ranges
    • name : string - descriptive text related to the id

    If AutoScan is not supported by device:

    { "supportedRanges":[] }

    If AutoScan is supported:

    {
      "supportedRanges":[
      {
        "id":0,
        "name":"Near"
      },
      {
        "id":1,
        "name":"Intermediate"
      },
      {
        "id":2,
        "name":"Far"
      }
      ]
    }
    Example
    declare let autoScanTrigger : any;
    autoScanTrigger.getSupportedRanges(
      (data) => {
        alert(JSON.parse(data).supportedRanges);
        if(this.supportedRanges.length == 0)
          alert("Device does not support Auto Scan");
      },
      (err) => { alert(err); }
    );

    .getCurrentRange(successCallback, errorCallback): Object

    Get the current range of the autoscan feature.

    Response

    currentRange : object - contains 2 fields:

    • id : integer
    • name : string

    If AutoScan is not supported by device:

    { "currentRange":null }

    If AutoScan is supported:

    {
      "currentRange":
      {
          "id":1,
          "name":"Intermediate"
      }
    }
    Example
    declare let autoScanTrigger : any;
    autoScanTrigger.getCurrentRange(
      (data) => {
        alert(JSON.parse(data).currentRange);
      },
      (err) => { alert(err); }
    );

    .setCurrentRange(id, successCallback, errorCallback): Object

    Set the current range of the autoscan feature.

    id : integer - should match one of the id values retrevied by the getSupportedRanges function.

    Response

    string with success message

    Example

    Set current range to "Intermediate"

    autoScanTrigger.setCurrentRange(
      0,
      (data) => { alert(data); },
      (err) => { alert(err); }
    );

    keyboardManager


    Function Description
    getAllAvailableTriggers Get all the available triggers of the device.
    setAllAvailableTriggers Set all the devices triggers on or off.
    setTriggers Set one or more triggers on or off.

    .getAllAvailableTriggers (successCallback, errorCallback): Object

    Get all the available triggers of the device.

    Response

    triggers : array - each object in the array contains:

    • enabled : boolean
    • id : integer
    • name : string

    Typical resopsnse:

    {
        "triggers":[
        {
            "enabled":true,
            "id":3,
            "name":"Front Trigger"
        },
        {
            "enabled":false,
            "id":4,
            "name":"Auto Scan Trigger"
        },
        {
            "enabled":false,
            "id":5,
            "name":"Motion Trigger"
        }
        ]
    }
    Example
    keyboardManager.getAllAvailableTriggers(
      (data) => { alert(JSON.parse(data).triggers); },
      (err) => { alert(err); }
    );

    .setAllAvailableTriggers(enable, successCallback, errorCallback): Object

    Set all the devices triggers on or off.

    Response

    string with success message

    Example

    Turn all triggers on.

    keyboardManager.setAllAvailableTriggers(
      true,
      (data) => { alert(data); },
      (err) => { alert(err); }
    );

    .setTriggers(config, successCallback, errorCallback): Object

    Set one or more triggers on or off. You will likely call getAllAvailableTriggers, edit the enabled flags of each returned object as desired, and then resubmit by calling setTriggers.

    config : array - each ojbect in the array represents an individual trigger. Each object in the array contains:

    • id : integer
    • enabled : boolean
    Response

    string with success message

    Example
    //an array os supported triggers
    triggers:{id: number, name: string, enabled: boolean}[]  = [];
    ...
    keyboardManager.getAllAvailableTriggers(
      (data) => {
        this.triggers = JSON.parse(data).triggers;
        this.triggers[0].enabled = false;
    
        keyboardManager.setTriggers(
          this.triggers,
          (data) => { alert(data); },
          (err) => { alert(err);}
        );
      },
      (err) => { alert(err); }
    );

    ledManager


    Function Description
    setLed Set various device LEDs.

    .setLed(ledConfig, successCallback, errorCallback): Object

    Set the various device LEDs. A list of enum values for LEDs can be found here.

    Response

    string with success message

    Example
    ledManager.setLed({"led": "LED_GOOD_READ", "enable": false}, null, null);

    scannerProperties


    Function Description
    edit Get a list of supported properties along with the state of each (enabled or disabled).
    store Apply changes to one or more properties with the values supplied.

    .edit(successCallback, errorCallback): Object

    Get a list of supported scanner properties along with the state of each (enabled or disabled).

    Response

    A single JSON object containing an object for each of the available symbologies. Each symbology contains, at a minimum, these fields:

    • enable : boolean - if scannner is set to detect this barcode type or not
    • supported : boolean - if the scanner supports the given barcode type or not
    {
      "keyboardWedge":{"enable":true,"supported":true},
      "aztec":{"enable":true,"supported":true},
      "codabar":{"enable":true,"supported":true},
      "code128":{"enable":true,"supported":true},
      "code39":{"enable":true,"supported":true},
      "code93":{"enable":false,"supported":true},
      "composite":{"enable":false,"supported":true},
      "datamatrix":{"enable":true,"supported":true},
      "digimarc":{"enable":false,"supported":false},
      "discrete25":{"enable":false,"supported":true},
      "ean13":{"enable":true,"supported":true},
      "ean8":{"enable":true,"supported":true},
      "gs1DataBar_14":{"enable":true,"supported":true},
      "gs1DataBar_Expanded":{"enable":true,"supported":true},
      "gs1DataBar_Limited":{"enable":true,"supported":true},
      "interleaved25":{"enable":true,"supported":true},
      "matrix25":{"enable":false,"supported":true},
      "maxicode":{"enable":false,"supported":true},
      "microQr":{"enable":false,"supported":true},
      "micropdf417":{"enable":false,"supported":true},
      "msi":{"enable":false,"supported":true},
      "p4State":{"enable":false,"supported":true},
      "pAus":{"enable":false,"supported":true},
      "pJap":{"enable":false,"supported":true},
      "pKix":{"enable":false,"supported":true},
      "pPlanet":{"enable":false,"supported":true},
      "pPostnet":{"enable":false,"supported":true},
      "pRM":{"enable":false,"supported":true},
      "pdf417":{"enable":true,"supported":true},
      "qrCode":{"enable":true,"supported":true},
      "upcA":{"enable":true,"supported":true},
      "upcE":{"enable":true,"supported":true}
    }
    Example
    properties : any = {};
    ...
    scannerProperties.edit(
      (data) => {
        this.properties =  JSON.parse(data);
        this.aztec = false;
        this.codabar = false;
        this.code128 = true;
        this.keyboardWedge = false;
      },
      (err) => { alert(err); }
    );

    .store(properties, successCallback, errorCallback): Object

    Apply changes to one or more symbologies with the values supplied in properties.

    Response

    string with success message

    Examples

    Enable UPC-E symbology

    scannerProperties.store({"upcE":{"enable":true,"supported":true}}, null, null);

    Disable keyboard wedge feature

    scannerProperties.store({"keyboardWedge":{"enable":false}}, null, null);

    Install

    npm i @datalogic/cordova-plugin-datalogic

    DownloadsWeekly Downloads

    8

    Version

    0.4.1

    License

    Apache-2.0

    Unpacked Size

    67.8 kB

    Total Files

    17

    Last publish

    Collaborators

    • datalogicmobile
    • bronson.mock
    • codybrookshear
    • sshankar