Ti.Barcode Module

Description

Lets you process 1D/2D barcodes.

Using this module with Titanium SDK 1.7.2 or earlier

To use this module with versions of the Titanium SDK of 1.7.2 or earlier you must install it local to the application project. To install, copy the module zip file into your application folder. If you install the module into the Titanium system folder then an exception will occur when you call the 'capture' method.

Warning when Updating to Barcode v1.5

With the 1.5 update to the Barcode Module, several breaking changes have been made. These changes were made to bring the iOS and Android modules in to full parity. When upgrading to 1.5, you will need to consider the following:

Accessing the Ti.Barcode Module

To access this module from JavaScript, you would do the following:

var Barcode = require('ti.barcode');

Functions

capture([args])

Brings up the camera and begins the capture sequence for processing a barcode. Takes one optional argument, a dictionary containing any of the following properties:

parse([args])

Parses a blob image for barcodes. Takes one required argument, a dictionary containing any of the following properties:

Events

Use Ti.Barcode.addEventListener() to process the following events that are sent from the module:

success

Sent upon a successful barcode scan. The event object contains the following fields:

error

Sent when an error occurs. The event object contains the following fields:

cancel

Sent when the scanning process is canceled. The event object contains the following fields:

Properties

allowRotation[boolean, defaults to false, iOS only]

Value that indicates if the barcode capture should analyze captured images in either portrait or landscape device orientation. (Warning: Analyzing both the captured image and the rotated version(s) of the image will increase the processing time of the capture.)

displayedMessage[string]

Controls the message that is displayed to the end user when they are capturing a barcode.

useFrontCamera[boolean, defaults to false]

Controls whether or not the front camera on the device will be used to capture barcodes. On Android, this requires API level 9 (Android OS 2.3) or higher. If no front camera is available, this will gracefully fall back to utilize whatever camera is available.

useLED[boolean, defaults to false]

Whether or not to use the LED when scanning barcodes (also known as the flashlight, torch, or some derivation thereof).

Barcode Result Type Constants

URL[int]

Value representing URL content

SMS[int]

Value representing SMS content

TELEPHONE[int]

Value representing telephone number content

TEXT[int]

Value representing text content

CALENDAR[int]

Value representing date content

GEOLOCATION[int]

Value representing geolocation content

EMAIL[int]

Value representing an email address

CONTACT[int]

Value representing contact information (vcard or mecard)

BOOKMARK[int]

Value representing bookmark content

WIFI[int]

Value representing wifi connection settings

Barcode Format Constants

FORMAT_NONE[int]

FORMAT_QR_CODE[int]

FORMAT_DATA_MATRIX[int]

FORMAT_UPC_E[int]

FORMAT_UPC_A[int]

FORMAT_EAN_8[int]

FORMAT_EAN_13[int]

FORMAT_CODE_128[int]

FORMAT_CODE_39[int]

FORMAT_ITF[int]

Usage

See example.

Author

Clint Tredway & Dawson Toth

Module History

View the change log for this module.

Feedback and Support

Please direct all questions, feedback, and concerns to info@appcelerator.com.

License

Copyright(c) 2010-2011 by Appcelerator, Inc. All Rights Reserved. Please see the LICENSE file included in the distribution for further details.