How to setup the Titanium+ Barcode module

You must Login before you can answer or comment on any questions.

I downloaded the barcode module, copied the folder into my projects root directory, added the <module version="1.0">ti.barcode</module> to tiapp.xml, and copied the example into the app.js file.

When I run the iPhone simulator and press the "Scan QR Code" button, nothing happens and I get this error in the Console:

[WARN] Exception in event callback. {

expressionBeginOffset = 462;

expressionCaretOffset = 478;

expressionEndOffset = 486;

line = 25;

message = &quot;Result of expression 'Titanium.Barcode' [undefined] is not an object.&quot;;

name = TypeError;

sourceId = 199841424;

sourceURL = &quot;file://localhost/Users/KG/Projects/Titanium%20Studio%20Workspace/QRtest/Resources/app.js&quot;;

}

Any help is appreciated...

6 Answers

The project module will be need copied to /Library/Application Support/Titanium/modules/iphone/ and not to project folder.

— answered 2 years ago by Adriano Paladini
answer permalink
1 Comment
  • Thanks for the help. I copied the project module to /Library/Application Support/Titanium/modules/iphone/ and I'm still getting the same error. Here's my app.js code:

    var barcode = require("ti.barcode");
     
    // open a single window
    var window = Ti.UI.createWindow({
      backgroundColor:'white'
    });
    window.open();
     
     
    var button = Ti.UI.createButton({
        title:"Scan QR Code",
        width:150,
        height:40,
        top:20
    });
     
    window.add(button);
     
    button.addEventListener('click',function()
    {
        Titanium.Barcode.capture({
            success: function(event)
            {
                alert("success = "+event.result);
            },
            cancel: function(event)
            {
                alert("cancel");
            },
            error: function(event)
            {
                alert("Error. "+event.message);
            }
        });
    });

    — commented 2 years ago by Karl Gusner

Thanks for the help. I copied the project module to /Library/Application Support/Titanium/modules/iphone/ and I'm still getting the same error. Here's my app.js code:

var barcode = require("ti.barcode");
 
// open a single window
var window = Ti.UI.createWindow({
  backgroundColor:'white'
});
window.open();
 
 
var button = Ti.UI.createButton({
    title:"Scan QR Code",
    width:150,
    height:40,
    top:20
});
 
window.add(button);
 
button.addEventListener('click',function()
{
    Titanium.Barcode.capture({
        success: function(event)
        {
            alert("success = "+event.result);
        },
        cancel: function(event)
        {
            alert("cancel");
        },
        error: function(event)
        {
            alert("Error. "+event.message);
        }
    });
});

I found the problem...

The sample code provided by the module 1.0 has this code at the top:

barcode = require("ti.barcode")

But later calls Titanium.barcode. Thus the above code needs to be:

Titanium.barcode = require("ti.barcode")

if you initialize it as `Titanium.barcode = ti.barcode = require("ti.barcode") you can then use either format to call the module methods.

i use ti.barcode module and i've this this error since one week. i don't undestand why. can you help me, please ?

Your Answer

Think you can help? Login to answer this question!