PDA

View Full Version : How to use phonegap plugins with ST2.3?



a3366873
9 Oct 2013, 2:30 AM
What are the steps necessary to use phonegap plugins inside ST?
Let's take bar code scanner plugin (https://github.com/wildabeast/BarcodeScanner) as an example. I installed it in my project. Do I have to include it somehow in app.js or index.html or is it included automatically by build command?
How can I access functionality provided by barcodescanner.js in my controller? Do I have to write my own wrapper like Ext.device.* classes or use it directly (and how)?
Do You have any examples integrating phonegap plugins?

Kurt001
9 Oct 2013, 3:03 AM
Are you using phonegap.build?

a3366873
9 Oct 2013, 3:29 AM
not sure if I understand your question... I use local build not build.phonegap.com service.

Kurt001
9 Oct 2013, 5:10 AM
Build Process
1) add the Barcodescanner.js to the app.json and in the root of the app
2) add the barcodescanner plugin to the config.xml as you would do for any phonegap app.

That's for the build process.

Call the Plugin
If you are not writing a simulator/phonegap switch you need

if (Ext.browser.is.Cordova){
var scanner = cordova.require("cordova/plugin/BarcodeScanner");
scanner.scan(onSuccess, onError);
} else {
return '123456789';
}

I did upload a switch for the barcodescanner. You can find it here (https://market.sencha.com/extensions/ext-ux-mgd-device-scanner)

loki4u
11 Oct 2013, 4:02 AM
hi Kurt001 (http://www.sencha.com/forum/member.php?246580-Kurt001)

var scanner = cordova.require("cordova/plugin/BarcodeScanner");

in the above line of your code in which folder "BarcodeScanner "points to ???????
and how to add the barcodescanner plugin to the config.xml?? plz

loki4u
11 Oct 2013, 4:29 AM
hi
Kurt001

i 'm getting error (http://www.sencha.com/forum/member.php?246580-Kurt001)
"cordova/plugin/BarcodeScanner" not found so can u tell me where this barcodescanner resides..????
http://www.sencha.com/forum/images/statusicon/user-offline.png

Kurt001
11 Oct 2013, 5:54 AM
I am right now on the leave. I will be back later and read your posts.

a3366873
15 Oct 2013, 12:40 AM
Thanks for sharing your extension Kurt.

I had same error as loki4u but I changed
var scanner = cordova.require("cordova/plugin/BarcodeScanner");
to
var scanner = cordova.plugins.barcodeScanner;

and now it works fine.

Kurt001
15 Oct 2013, 1:55 AM
I had same error as loki4u but I changed
var scanner = cordova.require("cordova/plugin/BarcodeScanner");
to
var scanner = cordova.plugins.barcodeScanner;

I will add this to the Installation documentation. Thanks for the feedback

Kurt001
15 Oct 2013, 2:19 AM
Updated the files. Please try this version. Should work for all now.

loki4u
17 Oct 2013, 12:43 AM
Thanks for sharing your extension Kurt and Thanks a3366873 (http://www.sencha.com/forum/member.php?629136-a3366873) for correction,
you both of saved my time. thanks once again don't have any words to say jus cheeeeeer:-):D

loki4u
17 Oct 2013, 12:44 AM
Thanks for sharing your extension Kurt.
and now it works fine. thanks a lot for your reply....:D

a3366873
29 Nov 2013, 5:49 AM
Anyone successfuly run Barcode Scanner plugin on ios?

Kurt001
30 Nov 2013, 3:31 AM
Anyone successfuly run Barcode Scanner plugin on ios?
Runs for me with PhoneGap 3.1.0 (as well as 3.0.0) and Barcodescanner 1.1.0 (as well as 1.0.6) and iOS on different devices.

a3366873
2 Dec 2013, 1:38 AM
do you use build.phonegap.com or local build?
I finally got it working by building with phonegap.com but I can't do it locally.

Kurt001
2 Dec 2013, 7:37 AM
@ a3366873:
I am using both. Did you add the file barcodescanner.js to the SenchaRoot?
As build.phonegap.com does this automatically you need to add it manually to a local build.
If you do add the barcodescanner.js and still it's not working, please send me a link to where you downloaded the barcodescanner.js from, so that I can look into it.