npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

phonegap-plugin-2mundos-barcodescanner-custom-ui

v7.0.15-2M

Published

You can use the BarcodeScanner plugin to scan different types of barcodes (using the device's camera) and get the metadata encoded in them for processing within your application.

Downloads

41

Readme

PhoneGap Plugin BarcodeScanner

================================

Build Status

Cross-platform BarcodeScanner for Cordova / PhoneGap.

Follows the Cordova Plugin spec, so that it works with Plugman.

Installation

This requires phonegap 5.0+ ( current stable v3.0.0 )

phonegap plugin add phonegap-plugin-barcodescanner

Older versions of phonegap can still install via the deprecated id ( stale v2.0.1 )

phonegap plugin add com.phonegap.plugins.barcodescanner

It is also possible to install via repo url directly ( unstable )

phonegap plugin add https://github.com/phonegap/phonegap-plugin-barcodescanner.git

Supported Platforms

  • Android
  • iOS
  • Windows (Windows/Windows Phone 8.1 and Windows 10)
  • Windows Phone 8
  • BlackBerry 10
  • Browser

Note: the Android source for this project includes an Android Library Project. plugman currently doesn't support Library Project refs, so its been prebuilt as a jar library. Any updates to the Library Project should be committed with an updated jar.

Note: Windows 10 applications can not be build for AnyCPU architecture, which is default for Windows platform. If you want to build/run Windows 10 app, you should specify target architecture explicitly, for example (Cordova CLI):

cordova run windows -- --archs=x86

Note: Since iOS 10 it's mandatory to add a NSCameraUsageDescription in the info.plist.

NSCameraUsageDescription describes the reason that the app accesses the user’s camera. When the system prompts the user to allow access, this string is displayed as part of the dialog box.

To add this entry you can pass the following variable on plugin install.

cordova plugin add phonegap-plugin-barcodescanner --variable CAMERA_USAGE_DESCRIPTION="To scan barcodes"

PhoneGap Build Usage

Add the following to your config.xml:

<!-- add a version here, otherwise PGB will use whatever the latest version of the package on npm is -->
<plugin name="phonegap-plugin-barcodescanner">
  <param name="CAMERA_USAGE_DESCRIPTION" value="To scan barcodes." />
</plugin>

On PhoneGap Build if you're using a version of cordova-android of 4 or less, ensure you're building with gradle:

<preference name="android-build-tool" value="gradle" />

Using the plugin

The plugin creates the object cordova.plugins.barcodeScanner with the method scan(success, fail).

The following barcode types are currently supported:

| Barcode Type | Android | iOS | Windows8 | Windows Phone 8 | BlackBerry 10 | |---------------|:-------:|:---:|:--------:|:---------------:|:-------------:| | QR_CODE | ✔ | ✔ | ✔ | ✔ | ✖ | | DATA_MATRIX | ✔ | ✔ | ✔ | ✔ | ✔ | | UPC_A | ✔ | ✔ | ✔ | ✔ | ✔ | | UPC_E | ✔ | ✔ | ✔ | ✔ | ✔ | | EAN_8 | ✔ | ✔ | ✔ | ✔ | ✔ | | EAN_13 | ✔ | ✔ | ✔ | ✔ | ✔ | | CODE_39 | ✔ | ✔ | ✔ | ✔ | ✔ | | CODE_93 | ✔ | ✖ | ✔ | ✔ | ✖ | | CODE_128 | ✔ | ✔ | ✔ | ✔ | ✔ | | CODABAR | ✔ | ✖ | ✔ | ✔ | ✖ | | ITF | ✔ | ✔ | ✔ | ✔ | ✔ | | RSS14 | ✔ | ✖ | ✔ | ✔ | ✖ | | PDF417 | ✔ | ✖ | ✔ | ✔ | ✖ | | RSS_EXPANDED | ✔ | ✖ | ✖ | ✖ | ✖ | | MSI | ✖ | ✖ | ✔ | ✔ | ✖ | | AZTEC | ✖ | ✖ | ✔ | ✔ | ✔ |

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);
      },
      {
          preferFrontCamera : true, // iOS and Android
          showFlipCameraButton : true, // iOS and Android
          showTorchButton : true, // iOS and Android
          torchOn: true, // Android, launch with the torch switched on (if available)
          saveHistory: true, // Android, save scan history (default false)
          prompt : "Place a barcode inside the scan area", // Android
          resultDisplayDuration: 500, // Android, display scanned text for X ms. 0 suppresses it entirely, default 1500
          formats : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED
          orientation : "landscape", // Android only (portrait|landscape), default unset so it rotates with the device
          disableAnimations : true, // iOS
          disableSuccessBeep: false // iOS and Android
      }
   );

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(cordova.plugins.barcodeScanner.Encode.TEXT_TYPE, "http://www.nytimes.com", function(success) {
            alert("encode success: " + success);
          }, function(fail) {
            alert("encoding failed: " + fail);
          }
        );

Windows quirks

  • Windows implementation currently doesn't support encode functionality.

  • On Windows 10 desktop ensure that you have Windows Media Player and Media Feature pack installed.

Windows Phone 8 quirks

Windows Phone 8 implementation currently doesn't support encode functionality.

BlackBerry 10 quirks

BlackBerry 10 implementation currently doesn't support encode functionality. Cancelling a scan on BlackBerry 10 is done by touching the screen.

Thanks on Github

So many -- check out the original iOS, Android and BlackBerry 10 repos.

Licence

The MIT License

Copyright (c) 2010 Matt Kane

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.