# Modules.Barcode
Add-on Barcode module
# 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
Whether or not to display helpful instructions or a changelog when the app is updated.
Default: true
Whether or not to allow the built-in ZXing menu to display.
Default: true
# allowRotation DEPRECATED
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
# apiName READONLY
The name of the API that this proxy corresponds to.
The value of this property is the fully qualified name of the API. For example, Titanium.UI.Button
returns Ti.UI.Button
.
# displayedMessage
Controls the message that is displayed to the end user when they are capturing a barcode.
# lifecycleContainer
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks will also be called on the proxy. Proxies that require the activity lifecycle will need this property set to the appropriate containing Window or TabGroup.
# useFrontCamera
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
Whether or not to use the LED when scanning barcodes (also known as the flashlight, torch, or some derivation thereof).
Default: false
# Methods
# applyProperties
Applies the properties to the proxy.
Properties are supplied as a dictionary. Each key-value pair in the object is applied to the proxy such that myproxy[key] = value.
Parameters
Name | Type | Description |
---|---|---|
props | Dictionary | A dictionary of properties to apply. |
Returns
- Type
- void
# canShow DEPRECATED
DEPRECATED SINCE 2.0.0
Whether the barcode scanner camera is allowed.
Returns
- Type
- Boolean
# capture
Brings up the camera and begins the capture sequence for processing a barcode.
Parameters
Name | Type | Description |
---|---|---|
dictionary | BarcodeCaptureDict | optional |
Returns
- Type
- void
# parse
Parses a blob image for barcodes.
Parameters
Name | Type | Description |
---|---|---|
dictionary | BarcodeParseDict | optional |
Returns
- Type
- void
# Events
# success
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 |
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
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 |
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
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 |
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
Used in the success event to specify the assumed content type of the barcode.
# CALENDAR
Used in the success event to specify the assumed content type of the barcode.
# CONTACT
Used in the success event to specify the assumed content type of the barcode.
# FORMAT_AZTEC
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_CODABAR
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_CODE_128
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_CODE_39
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_CODE_39_MOD_43 DEPRECATED
DEPRECATED SINCE 5.0.0
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_CODE_93
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_DATA_MATRIX
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_EAN_13
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_EAN_8
Used in the capture and parse methods to specify accepted formats.
# FORMAT_INTERLEAVED_2_OF_5 DEPRECATED
DEPRECATED SINCE 5.0.0
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_ITF
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_MAXICODE
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
DEPRECATED SINCE 5.0.0
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_PDF_417
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_QR_CODE
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_RSS_14
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_RSS_EXPANDED
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_UPC_A
Used in the capture and parse methods and the success event to specify accepted formats.
# FORMAT_UPC_E
Used in the capture and parse methods and the success event to specify accepted formats.
# GEOLOCATION
Used in the success event to specify the assumed content type of the barcode.
# TELEPHONE
Used in the success event to specify the assumed content type of the barcode.