play_store_512

Cordova Google code scanner plugin demo

Demo app for testing the cordova-plugin-google-code-scanner, which allows scanning of codes without requesting camera permissions using the new Google Play Services barcode API. Source code available in GitHub.

Apache Cordova logo phonegap

Introduction

The Google code scanner allows scanning of codes with the new play-services-code-scanner library. This API is based on the ML Kit for Android, but with a drastically smaller footprint, there’s no need to bundle the complete ML Kit with your app. Instead, the code scanner only requires a small UI module downloaded on-demand by Google Play Services on first use.

This API is offered in beta, which means it might be changed in backward-incompatible ways and is not subject to any SLA or deprecation policy.

Prerequisites

  • Android 5+
  • Google Play Services updated

Android screenshots

Methods

This is a summary of the demo app’s methods. Refer to plugin’s README for details

startScan

Opens the code scanner view to scan barcode with the selected format. If you know which barcode formats you expect to read, you can improve the speed of the barcode detector by configuring it to only detect those formats.

To detect multiple formats, type the sum of the Barcode constants to the provided text area.

getBarcodeConstant

Retrieve the Barcode format constant value by its String name. Useful to scan new barcode formats added in the future.

Predefined barcode formats

The following barcode constants are pre-defined by the plugin for your convenience:

  • FORMAT_ALL_FORMATS
  • FORMAT_CODE_128
  • FORMAT_CODE_39
  • FORMAT_CODE_93
  • FORMAT_CODABAR
  • FORMAT_DATA_MATRIX
  • FORMAT_EAN_13
  • FORMAT_EAN_8
  • FORMAT_ITF
  • FORMAT_QR_CODE
  • FORMAT_UPC_A
  • FORMAT_UPC_E
  • FORMAT_PDF417
  • FORMAT_AZTEC

Remarks

  • Camera usage permission not required.
  • Whenever the Google Play Store app is disabled, the UI module won’t be downloaded.

Download demo app

Feedback

Use the comments section here for demo app-related issues, and the GitHub issues tracker for plugin-related ones.

More plugin demos