1.0.2 • Published 6 years ago

cordova-internal-plugins-multiscanner v1.0.2

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
6 years ago

Sephora cordova plugins - BarcodeScannerPlugin

Presentation

Cross-platform BarcodeScanner for Cordova / PhoneGap by Xebia, based on BarcodeScanner plugin for phonegap. Modified for Infinibeauty/Mysephora.

Features

  • Scan a barcode with the camera or the Linea Pro device.

Compatibility

  • iOS only
  • this version is compatible with Infinibeauty and MySephora, on iPod 5 only.

Installation

Add as a cordova dependency, in config.xml (with Cordova 6.x or higher)

 <plugin name="cordova-internal-plugins-multiscanner" spec="http://gitlab.estore.caas/cordova-plugins/multiscanner#1.0.0" />

Using the plugin

The plugin creates the object cordova/plugin/BarcodeScanner with the method scan(success, fail).

The following barcode types are currently supported:

iOS

  • QR_CODE
  • DATA_MATRIX
  • UPC_E
  • UPC_A
  • EAN_8
  • EAN_13
  • CODE_128
  • CODE_39
  • ITF

success and fail are callback functions. Success is passed an object with data, type and cancelled properties. Data is the text representation of the barcode data, type is the type of barcode detected and cancelled is whether or not the user cancelled the scan.

A full example could be:

   cordova.plugins.barcodeScanner.scan(
      function (result) {
          alert("We got a barcode\n" +
                "Result: " + result.text + "\n" +
                "Format: " + result.format + "\n" +
                "Cancelled: " + result.cancelled);
      }, 
      function (error) {
          alert("Scanning failed: " + error);
      }
   );

Encoding a Barcode

The plugin creates the object cordova.plugins.barcodeScanner with the method encode(type, data, success, fail). Supported encoding types:

  • TEXT_TYPE
  • EMAIL_TYPE
  • PHONE_TYPE
  • SMS_TYPE

A full example could be:

   cordova.plugins.barcodeScanner.encode(BarcodeScanner.Encode.TEXT_TYPE, "http://www.nytimes.com", function(success) {
  	        alert("encode success: " + success);
  	      }, function(fail) {
  	        alert("encoding failed: " + fail);
  	      }
  	    );