barcodeScanner-Plugin on iOS cordova 1.5/1.6; phonegap 1.4

379 views
Skip to first unread message

HarryFu

unread,
Apr 12, 2012, 1:41:18 PM4/12/12
to phon...@googlegroups.com
Hello together,
I am new at programming with Phonegap and are very confused by all these namespace changes and compatibility problems.
 
I am trying to get the simple barcodeScanner-Plugin from the git repository running in a fresh XCode-Project. I have been trying phonegap/cordova versions from 1.4.1 to 1.6 with plugins from the iOS and iPhone folder.
 
Cordova 1.5/1.6 doesn't work at all with the Plugin from the iOS folder. If I try to debug the js code with alerts, I get an "undefined" message at window.plugins.barcodeScanner line. I have read in an phonegap-discussion that the functions hasResource and addResource are deprecated and doesn't work no more. But they are used in the barcodescanner.js file from the iOS folder. Can this be the problem? 
 
Cordova 1.4.1 works together with the Plugin from the iPhone folder. The app starts and the scanning mask opens. If i cancel the scanning-process everything works fine but when i scan an Barcode or QR Code the programmed alert opens and the app freezes. I cant find a working solution. Can anybody help me on this?
 
My index.html file looks like this:
 
<!DOCTYPE html>
<html>
    <head>
        <title></title>
       
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
        <meta charset="utf-8">
            
            <script type="text/javascript" charset="utf-8" src="cordova-1.6.0.js"></script>
            <script type="text/javascript" charset="utf-8" src="barcodescanner.js"></script>
            <script type="text/javascript">
                var scanCode = function() {
                    alert(window.plugin.barcodeScanner);
                    window.plugins.barcodeScanner.scan(
                                                       function(result) {
                                                       alert("Scanned Code: " + result.text
                                                             + ". Format: " + result.format
                                                             + ". Cancelled: " + result.cancelled)
                                                       }, function(error) {
                                                       alert("Scan failed: " + error)
                                                       });
                }
                </script>
            </head>
    <body>
                <h1>Barcode Scanner</h1>
                <a href="#" onclick="scanCode();">Scannen</a>
    </body>
</html>
 
Thanks
 
 
 

Shazron

unread,
Apr 12, 2012, 8:49:02 PM4/12/12
to phon...@googlegroups.com
The plugin author needs to upgrade it for 1.6.0. There are guidelines
in the "Cordova Plugin Upgrade Guide" that you can point him/her to.

> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com

Gokhan

unread,
Apr 13, 2012, 12:28:22 PM4/13/12
to phon...@googlegroups.com
Hi, I run phonegap app in android using barcode plugin. But i'm new at xcode, can you help me about how to add plugin ios, I tryed to add, but when i run app, it closed. thanks.

12 Nisan 2012 Perşembe 16:41:18 UTC+3 tarihinde HarryFu yazdı:

HarryFu

unread,
Apr 15, 2012, 5:26:21 PM4/15/12
to phon...@googlegroups.com
I have tried to change all the "Cordova" to "cordova" how its written in the Cordova Plugin Upgrade Guide but doesn't get any changes. How i read in this Thread. cordova.hasResource and cordova.addResource are deprecated and doesn' work any more. I also can not find them in cordova-1.6.0.js or cordova-1.5.0.js I think this could be the problem, because they are used in the barcodescanner.js file. Can anybody explain to me how to get this running again?

If anybody has a working version with phonegap 1.4.1 or cordova 1.5 it would be nice if he or she could send me some help to get the plugin running. It would be fine for me to use an oder version of phonegap for my project. As I read from the documentation in the barcodescanner plugin, this should work with 1.4.1 and 1.5, but I doesn't get this running.

Android and Blackberry version of this plugin works fine with 1.4.1 and 1.5 but iOS version seems kind of tricky.

Thanks for your help.

> phonegap+unsubscribe@googlegroups.com

HarryFu

unread,
Apr 15, 2012, 5:38:17 PM4/15/12
to phon...@googlegroups.com
As far as i got, the plugin doesn't work with cordova version 1.6 and 1.5. With 1.4.1 it works until i get back a read out string, then the app freezes. Haven't got something working on iOS. Android and Blackberry works fine, but iOS seems very tricky.

@RandyMcMillan

unread,
Apr 15, 2012, 10:00:59 PM4/15/12
to phonegap
The Barcodescanner was tested on 1.5.0.

This was an example I added to the plugin bundle ->
https://github.com/phonegap/phonegap-plugins/tree/master/iOS/BarcodeScanner/Example
(don't accidentally add this folder to your app project)

Please note the plugin only works on real hardware.

This plugin hasn't been updated to 1.6.0 yet...

feel free to make the appropriate edits and submit to the /iOS repo

(:

-RM

HarryFu

unread,
Apr 24, 2012, 8:36:26 AM4/24/12
to phon...@googlegroups.com
@RandyMcMillan: Thanks for your help. Tried your example and got it working well on 1.5.0. Don't know, what i did wrong before.
 
But now I have another question: Is it possible to open the camera preview in a html document. I would like to see the camera stream in a div element on my own webview instead of a fullscreen overlay over all my navigation. Does anybody know a way to achieve this?
Reply all
Reply to author
Forward
0 new messages