-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on scanner click function #1
Comments
Hi Marc,
If it is in your project subfolder, then it should be working in phonegap. Have you tried building locally (either Android and iOS) and testing it? I typically do that using ripple or the native tools before uploading to PhoneGap.
Thanks for pointing that out. When I first set this PhoneGap required the config.xml to be in www. They have changed that since then. You might try copying your config.xml to the xml folder just to see whether that makes a difference. If that works, you may need to update your cordova and phonegap installations. If you are still having trouble tomorrow, let me know and I will see if i can build a new example with updated versions of cordova, phonegap, angularjs and ionic. |
It builds and runs in the ios emulator successfully if that's what you mean. The barcode scanning functionality doesn't word anywhere. I assumed this was because the camera doesn't exist in the emulator. I will look into ripple. I'm fairly new to native app development.
I assumed that was the issue and moved it accordingly. I'm running cordova 3.5, installed via the CLI. There weren't any instructions regarding PhoneGap. Have I missed something? I thought it was bundled with a version.
If it's super easy for you then I would appreciate the help. I've been running into dead ends for the past few days and finally decided to reach out because your example is applicable to my project. Let me know if you have any questions about my setup. I'm using AngularJS, Cordova CLI and Xcode to build and deploy the app on an iPhone 5 (7.1.2). |
I am happy to help. I appreciate you taking the time to try my post and report that you are having problems. I would like to get it working so that everyone can benefit. I am not sure how quickly I can turn the example but I will try to do it as soon as possible. |
How did you install the plugin into your project? Did you use this command?
When I did that I had to remove and then re-add my platforms to get everything working:
I then manually checked for the plugin for both android and ios for a simple test app: test01:
Does this help at all? |
I also verified that the current PgBarcodeScanner application worked in phonegap: https://build.phonegap.com/apps/992106/share for ios, android and windows. |
I successfully completed all of your steps. All the responses in the CLI are identical. All the files are in the right place. I'm still getting the same error when i click "Click to scan". The only variable now must be on the deployment end. I must be doing something incorrectly... After your build process, I test the app 1 of 2 ways which both have resulted in the same errors in the console.
Clicking the scan button produces the same error message in both the simulator and the real device:
How are you confirming that the barcode scanner worked? What does your deployment to an ios device/simulator process look like? Thanks again for all the help by the way. :) |
It sounds like you are doing everything correctly. Hmmmm.....
I confirmed it by downloading it to a Samsung S3 and an iPhone 4 but it should be possible to confirm it in ripple by telling ripple to use your laptop/workstation camera. Actually I just tried it in ripple and it didn't work which surprises me because I am almost sure that I originally tested it there using my laptop camera. Let me see whether I can get it working in ripple and get back to you.
The deployment was done by phonegap so I don't really know. I just used the QR code to do the installation on my device.
Glad to help. I want to figure out how to get it working for you. If it would help, I would be glad to send you the entire contents of the project directory. |
I am running iOS 7.1.2 on my iphone4. When I run ripple I do not see a popup complaining about BarcodeScanner.scan. That is suspicious. Are you building your environment using phonegap, cordova or ionic? |
Just to be 100% sure. By build do you mean:
|
Yup and that is what I used. Have you tried zipping your www directory and submitting it phonegap? |
Sorry, clicked the wrong button... |
I've never done it with PhoneGap before. I'll have to look up how to do that. Any quick resources I should look at for getting it on an iPhone? Is http://build.phonegap.com the best way? |
That is interesting. I wonder if my app does not work unless it is used for phonegap. That would certainly explain why you are having problems. Phonegap is pretty easy to use. Here are the steps.
For Apple devices you will need the usual Apple ID stuff. I am going to check into why the project does not work without phonegap. |
I am not sure if this is interesting to you but I just figured out how to get the barcode scanner working in emulation mode under android. Here are the steps.
I verified that it is working (using a newer version). |
Good news. I've actually got it working now. I wrote a service that seemed to work. I think there might be an error in your service that is preventing it from working on iOS for some reason. I can't be sure though. Here's my code. I used the same defer/resolve as your service. app.service('scanService', function($q) {
/* public */
return({
scan: scan
});
function scan() {
// The plugin operates asynchronously so a promise
// must be used to display the results correctly.
var deferred = $q.defer();
var scanner = cordova.require("cordova/plugin/BarcodeScanner");
scanner.scan(function(result) {
deferred.resolve({'error':false, 'result': result});
}, function(error) {
deferred.resolve({'error':true, 'result': error.toString()});
});
return deferred.promise;
}
}); |
That is excellent. Thank you Marc, I really appreciate your help. I will update with your changes and test. |
Config.xml has the following added:
Is there a reason why your config.xml is in www in stead of in the project root?
Any ideas where I might look to confirm that
com.phonegap.plugins.barcodescanner.BarcodeScanner
has been installed correctly? (it's appearing in the project /plugins/ folder)The text was updated successfully, but these errors were encountered: