Ionic 2 “Support” on Zebra Enterprise Devices

Over the past few months I have seen an increasing number of questions around using Ionic 2 on Zebra Enterprise devices.  Right now there is no official Ionic Native plugin to easily expose scanning and other enterprise functionality available on Zebra devices.

What you can do (and this seems to be the most popular approach here) is to use DataWedge on the device to control scanning functionality and have DataWedge output an Intent whenever a barcode is scanned.  The Ionic 2 application just then has to listen for the intents coming from DataWedge and voila, it has received scanned data.

Obviously, Ionic 2 relies on Cordova to deploy to mobile devices.  Previously I have written about integrating DataWedge with your Cordova application but that was written back in August 2016 and since that time there has been an increasing prevalence of TypeScript and the paradigm shift between Angular 1.x and Angular 2.x (and Ionic 1.x to 2.x).  A number of developers were relying on the advice given for Cordova and fitting that square peg into the round hole of an Ionic 2 application.

My advice for creating an Ionic 2 application to run on Zebra enterprise mobile computers is as follows:

  • Use DataWedge to control the scanner and have DataWedge output Intents on each successful scan
  • Receive those Intents in your Ionic 2 application with the WebIntent native plugin, https://ionicframework.com/docs/native/web-intent/
    • Note: There seems to be some problem with webIntent.registerBroadcastReceiver not exposing a callback, I advise calling into the implementation of webIntent directly:
    • (<any>window).plugins.intentShim.registerBroadcastReceiver(options, callback);
  • Control DataWedge (if required) via the DataWedge Intent API also using the WebIntent native plugin, https://ionicframework.com/docs/native/web-intent/

To help get you started, I have put together a very simple sample application, https://github.com/darryncampbell/DataWedgeIonic2.  This sample app will only receive intents via DW, not send them via the DW Intent API but it should be enough to get going.  Please see the ReadMe for setup instructions.  It is tested with the latest versions (at the time of writing) of Ionic (3.19.0), Cordova (7.1.0) and Cordova’s Android platform (6.3.0)

7 Replies to “Ionic 2 “Support” on Zebra Enterprise Devices”

  1. apply plugin: ‘com.android.application’

    android {
    compileSdkVersion ‘Zebra Technologies Corp:EMDK APIs:23’
    buildToolsVersion ‘26.0.2’

    defaultConfig {
    applicationId “com.symbol.barcodesample1”
    minSdkVersion 19
    targetSdkVersion 23
    versionCode 8
    versionName “6.6.1”
    }

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
    release {
    minifyEnabled false
    proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’
    }
    }
    }

    this is the “original” gradle I have found in a Zebra demo prj

    • Nothing wrong at all with copying barcodesample1 🙂 I believe your app will still compile even without the jar but I am happy to be wrong… I did try it earlier today & it worked but I have not touched flutter before so I’m no expert!

Leave a Reply

Your email address will not be published. Required fields are marked *