Update - April 2017


This blog received a major overhaul in April 2017 to transition away from the previously used 3rd party plugins and demonstrate the use of the recent DataWedge 6.2 APIs.


DataWedge Intent Interface

DataWedge is a value-add of all Zebra Technologies devices (formally Symbol and Motorola Solutions) that allows barcode capture and configuration without the need to write any code.  This application will demonstrate how to use Android intents to add DataWedge scanning functionality to your application


Quick Start - Getting this Demo running


>git clone https://github.com/darryncampbell/DataWedgeCordova.git 
>cd DataWedgeCordova 
>cordova platform add android 
Plug in Zebra device Follow instructions under "Configuring Datawedge" (below) 
>cordova run android Scan a barcode


Getting Started

This section walks through the steps to create a new Cordova application that utilises DataWedge for scanning.


Create a cordova application that will run on Android

cordova create DataWedgeCordova com.zebra.datawedgecordova DataWedgeCordova 
cordova platform android 


We will use a 3rd party plugin to handle sending and receiving Intents to the DataWedge service.  Any plugin capable of sending or receiving generic intents and interpreting the extra bundle into JSON should work:

cordova plugin add https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent.git 


Note that a previous version of this blog used different 3rd party plugins which have since been deprecated.  I wrote my own generic plugin to handle intents and released it under MIT to aid customers who wish to integrate DataWedge and Cordova but this should not be considered supported software by Zebra Technologies


Configuring Datawedge

DataWedge can be configured to send intents whenever it scans barcodes.  More detailed help is available at the official documentation but for the purposes of this demo I will include the pertinent steps.  There are more sophisticated ways to configure DataWedge but this section will cover the basics.


  • Create a new DataWedge profile (Applications --> DataWedge --> Menu --> New Profile).  This will be the profile that will be active when our Cordova application is in the foreground.  Give it a name e.g. DataWedgeCordova and click into it to configure.
  • The next step requires our Cordova application to have previously run on the device so if you have not already done so, `cordova run android`
  • Back in DataWedge configuration associate the Cordova application with our DW profile


  • Scroll down to the Intent Output section of DW configuration and enable intents to start our activity:
    • Intent Action: com.zebra.datawedgecordova.ACTION
    • Intent Category: leave blank
    • Intent delivery: Broadcast intent




Add Code to the Cordova application

Now to hook up our logic to listen for and send intents.


Listening for intents

Since we configured DataWedge to send barcode data to our application via an implicit broadcast intent we can use the 3rd party plugin to register a broadcast receiver:


    filterActions: ['com.zebra.datawedgecordova.ACTION'],
    filterCategories: ['com.android.intent.category.DEFAULT']},    
    function(intent) {    //  Broadcast received    
        console.log('Received Intent: ' + JSON.stringify(intent.extras));
        if (intent.extras["com.symbol.datawedge.data_string"] != null)   
            document.getElementById('broadcastData').innerHTML = "Scan: " + intent.extras["com.symbol.datawedge.data_string"];    


And in index.html


<div class="event" id="broadcastData"></div>


Sending intents

DataWedge supports an intent based API documented here. The API is somewhat limited but supports initiating the scanner via software (simulating a trigger press), disabling the scanner entirely and various DataWedge profile operations.  We'll be adding features to our application to simulate a trigger press and disable / enable the scanner through that Intent interface:


To simulate a trigger press:

       action: 'com.symbol.datawedge.api.ACTION_SOFTSCANTRIGGER',
       extras: {   'com.symbol.datawedge.api.EXTRA_PARAMETER': 'TOGGLE_SCANNING'   }
    function() {},     
    function() {}


To disable the scanner:

       action: 'com.symbol.datawedge.api.ACTION_SCANNERINPUTPLUGIN',
       extras: {    'com.symbol.datawedge.api.EXTRA_PARAMETER': 'DISABLE_PLUGIN'   }
    function() {},
    function() {} 


And hook up our logic to the UI:

document.getElementById("scanButton").addEventListener("click", startSoftTrigger);
document.getElementById("disableScanningButton").addEventListener("click", disableEnableScanning);


Now deploy & launch your app.  You are able to scan barcodes and exercise the functionality:





DataWedge versions

As DataWedge continues to evolve its capabilities continue to be enhanced. At the time of writing there are two different API levels for DataWedge, 6.2 and pre-6.2, as documented here. Future updates will continue to enhance datawedge but the same principles should apply to any updated intent API, that it can be accessed through 3rd party Cordova plugins.



This technique for adding scanning capabilities to a Cordova application represents the most generic possible solution.  We appreciate your developer feedback:

  • Would you prefer a dedicated Cordova plugin for Javascript?
  • Would you like to access EMDK profile functionality through Cordova?
  • Would you rather a dedicated Javascript interface as opposed to relying on third party plugins?
  • Are you interested in JavaScript development outside of Cordova e.g. ReactNative or NativeScript for your Enterprise application


Please feel free to raise github issues on the repository or post comments to this blog.