GithubHelp home page GithubHelp logo

shashank2406 / cordova-plugin-zebra-scanner-ios Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 4.0 5.8 MB

Cordova Wrapper for iOS Zebra Scanner SDK

License: MIT License

Objective-C 63.91% C 10.44% JavaScript 25.65%
cordova-plugin zebra ios

cordova-plugin-zebra-scanner-ios's Introduction

Gitter Zebra Scanner on npm

Cordova Plugin Zebra Scanner for iOS

This Cordova plugin is a wrapper for the official iOS Zebra Scanner SDK.

Installation

For Ionic Project

ionic cordova plugin add cordova-plugin-zebra-scanner-ios

You also need to install ionic native bluetooth-serial.

For ionic versions >4 use the following Command:

ionic cordova plugin add cordova-plugin-bluetooth-serial
npm install --save @ionic-native/bluetooth-serial

Now you have to add BluetoothSerial to your app.module.ts (for ionic Version 4 you need @ionic-native/[email protected]):

...
// /npx is required for ionic 4
import { BluetoothSerial } from '@ionic-native/bluetooth-serial/ngx';
...
providers: [
 ...,
 BluetoothSerial
],

For Cordova Project

cordova plugin add cordova-plugin-zebra-scanner-ios

Example

For Ionic Project (Connection for Zebra CS4070)

import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { BluetoothSerial } from '@ionic-native/bluetooth-serial';
import { Platform } from 'ionic-angular';

declare var window: any;

@Injectable()
export class BluetoothService {

   // Change your Scanner here
   scannerName: string = 'cs4070';

   constructor () {
      document.addEventListener('zebra.barcodeData', this.bluetoothDataRead.bind(this), false);
   }
   
   /**
     * Demo for Output console.logs for connection status
     */
   CheckDeviceConnected (): void {
      window.ZebraScanner
         .getAvailableScanners()
         .then((res) => {
            if (res.length) {
               res.filter(item => {
                  if (String(item.name).toLowerCase().indexOf(this.scannerName) !== -1) { 
                     this.scannerID = item.scannerID;
                     window.ZebraScanner.
                        establishCommunicationSession(item.scannerID)
                        .then(data => {
                           console.log("Device Connected")
                        }, error => {
                           console.log(error)
                        });
                  }
               });
            } else {
               console.log("No Device Found")
            }
         });
       }
    }

    bluetoothDataRead (event?): void {
         console.log("Read Success",event.detail.barcodeData);
    }
      
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.