# Modules.Barcode

Add-on Barcode module

Availability
3.1.0
3.2.0

# Overview

# System Requirements

  • Titanium SDK 5.5.1+
  • Camera Permissions set in your tiapp.xml:
<ti:app>
  <!-- ... -->
  <ios>
    <plist>
      <dict>
        <key>NSCameraUsageDescription</key>
        <string>We need permission to access your device camera.</string>
      </dict>
    </plist>
  </ios>
  <!-- ... -->
</ti:app>

# Properties

# allowInstructions

Availability
3.1.0
allowInstructions :Boolean

Whether or not to display helpful instructions or a changelog when the app is updated.

Default: true


# allowMenu

Availability
3.1.0
allowMenu :Boolean

Whether or not to allow the built-in ZXing menu to display.

Default: true


# allowRotation DEPRECATED

Availability
3.2.0
allowRotation :Boolean

DEPRECATED SINCE 2.0.0

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.)

  • true: Captured images will be analyzed in both portrait and landscape orientation.
  • false [default]: Captured images will be analyzed using only the current device orientation.

Default: false


# displayedMessage

Availability
3.1.0
3.2.0
displayedMessage :String

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


# useFrontCamera

Availability
3.1.0
3.2.0
useFrontCamera :Boolean

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.

Default: false


# useLED

Availability
3.1.0
3.2.0
useLED :Boolean

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

Default: false

# Methods

# cancel

Availability
3.1.0
3.2.0
cancel() void

Cancels and closes the currently open capture window.

Returns

Type
void

# canShow DEPRECATED

Availability
3.2.0
canShow() Boolean

DEPRECATED SINCE 2.0.0

Whether the barcode scanner camera is allowed.

Returns

Type
Boolean

# capture

Availability
3.1.0
3.2.0
capture([dictionary]) void

Brings up the camera and begins the capture sequence for processing a barcode.

Parameters

Name Type Description
dictionary BarcodeCaptureDict

optional

Returns

Type
void

# parse

Availability
3.1.0
3.2.0
parse([dictionary]) void

Parses a blob image for barcodes.

Parameters

Name Type Description
dictionary BarcodeParseDict

optional

Returns

Type
void

# Events

# success

Availability
3.1.0
3.2.0

Fired upon a successful barcode scan.

Properties

Name Type Description
format String | Number

The format of the barcode. Reported with a value of one of the Modules.Barcode.FORMAT_* constant if matching a known format. Otehrwise, may report a string value.

result String

The raw contents of the barcode

code Number

The activity result code from the scanning activity. Use the result constants defined in the Titanium.Android namespace

RESULT_CANCELED, RESULT_FIRST_USER, or RESULT_OK

contentType Number

The type of barcode content. Use the constants defined in this module to determine which.

data Object

The parsed fields associated with the contentType.

bytes Titanium.Buffer

The raw byte array contents of the barcode, when available

source Object

Source object that fired the event.

type String

Name of the event fired.

bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.


# error

Availability
3.1.0
3.2.0

Sent when an error occurs.

Properties

Name Type Description
message String

The error message

code Number

The activity result code from the scanning activity. Use the result constants defined in the Titanium.Android namespace

RESULT_CANCELED, RESULT_FIRST_USER, or RESULT_OK

source Object

Source object that fired the event.

type String

Name of the event fired.

bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.


# cancel

Availability
3.1.0
3.2.0

Sent when the scanning process is canceled.

Properties

Name Type Description
message String

The error message

code Number

The activity result code from the scanning activity. Use the result constants defined in the Titanium.Android namespace

RESULT_CANCELED, RESULT_FIRST_USER, or RESULT_OK

source Object

Source object that fired the event.

type String

Name of the event fired.

bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

# Constants

# BOOKMARK

Availability
3.1.0
3.2.0
BOOKMARK :Number

Used in the success event to specify the assumed content type of the barcode.


# CALENDAR

Availability
3.1.0
3.2.0
CALENDAR :Number

Used in the success event to specify the assumed content type of the barcode.


# CONTACT

Availability
3.1.0
3.2.0
CONTACT :Number

Used in the success event to specify the assumed content type of the barcode.


# EMAIL

Availability
3.1.0
3.2.0
EMAIL :Number

Used in the success event to specify the assumed content type of the barcode.


# FORMAT_AZTEC

Availability
3.1.0
3.2.0
FORMAT_AZTEC :Number

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_CODABAR

Availability
3.1.0
3.2.0
FORMAT_CODABAR :Number

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_CODE_128

Availability
3.1.0
3.2.0
FORMAT_CODE_128 :Number

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_CODE_39

Availability
3.1.0
3.2.0
FORMAT_CODE_39 :Number

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_CODE_39_MOD_43 DEPRECATED

Availability
3.2.0
FORMAT_CODE_39_MOD_43 :Number

DEPRECATED SINCE 5.0.0

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_CODE_93

Availability
3.1.0
3.2.0
FORMAT_CODE_93 :Number

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_DATA_MATRIX

Availability
3.1.0
3.2.0
FORMAT_DATA_MATRIX :Number

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_EAN_13

Availability
3.1.0
3.2.0
FORMAT_EAN_13 :Number

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_EAN_8

Availability
3.1.0
3.2.0
FORMAT_EAN_8 :Number

Used in the capture and parse methods to specify accepted formats.


# FORMAT_INTERLEAVED_2_OF_5 DEPRECATED

Availability
3.1.0
3.2.0
FORMAT_INTERLEAVED_2_OF_5 :Number

DEPRECATED SINCE 5.0.0

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_ITF

Availability
3.1.0
3.2.0
FORMAT_ITF :Number

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_MAXICODE

Availability
3.1.0
3.2.0
FORMAT_MAXICODE :Number

Used in the capture and parse methods and the success event to specify accepted formats.

Please note that Maxicode support is considered Beta, and requires using the pureBarcode hint.


# FORMAT_NONE DEPRECATED

Availability
3.1.0
3.2.0
FORMAT_NONE :Number

DEPRECATED SINCE 5.0.0

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_PDF_417

Availability
3.1.0
3.2.0
FORMAT_PDF_417 :Number

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_QR_CODE

Availability
3.1.0
3.2.0
FORMAT_QR_CODE :Number

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_RSS_14

Availability
3.1.0
3.2.0
FORMAT_RSS_14 :Number

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_RSS_EXPANDED

Availability
3.1.0
3.2.0
FORMAT_RSS_EXPANDED :Number

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_UPC_A

Availability
3.1.0
3.2.0
FORMAT_UPC_A :Number

Used in the capture and parse methods and the success event to specify accepted formats.


# FORMAT_UPC_E

Availability
3.1.0
3.2.0
FORMAT_UPC_E :Number

Used in the capture and parse methods and the success event to specify accepted formats.


# GEOLOCATION

Availability
3.1.0
3.2.0
GEOLOCATION :Number

Used in the success event to specify the assumed content type of the barcode.


# SMS

Availability
3.1.0
3.2.0
SMS :Number

Used in the success event to specify the assumed content type of the barcode.


# TELEPHONE

Availability
3.1.0
3.2.0
TELEPHONE :Number

Used in the success event to specify the assumed content type of the barcode.


# TEXT

Availability
3.1.0
3.2.0
TEXT :Number

Used in the success event to specify the assumed content type of the barcode.


# UNKNOWN

Availability
3.1.0
3.2.0
UNKNOWN :Number

Used in the success event to specify the assumed content type of the barcode.


# URL

Availability
3.1.0
3.2.0
URL :Number

Used in the success event to specify the assumed content type of the barcode.


# WIFI

Availability
3.1.0
3.2.0
WIFI :Number

Used in the success event to specify the assumed content type of the barcode.