Software Archive
Read-only legacy content
17061 Discussions

Help needed to install PhoneGap Plugin BarcodeScanner.

Tony_D_1
Beginner
721 Views

Hi,

I am new to app development and am in the process of building a JQuery cross platform app using Intel XDK.  I need to build in a barcode scanner and want to use PhoneGap BarcodeScanner plugin, but I am really unsure how to go about this.  I am able to import the plugin into my project, but it doesn't show up in my developer tab files. I am also not sure how to go about building the javascript file to link to it as there seems to be no documentation with the app explaining anything.  

Can anyone point me in the direction of a good tutorial explaining how to import/install a 3rd party plugin into XDK and how to link to it using javascript.

Thanks in advance.

TonyD

0 Kudos
7 Replies
Anusha_M_Intel1
Employee
721 Views

Hi Tony,

Here is our documentation on importing third party plugins. https://software.intel.com/en-us/xdk/docs/adding-third-party-plugins-to-your-xdk-cordova-app

It will not show up in your develop tab files. You can only view the plugin details from Project tab -> Plugin -> Third party plugin. 

You do not have to do anything extraordinary to link your plugin to your project. Just start calling your plugin methods in your project. This is  the most popular Cordova barcode scanner plugin out there: https://github.com/phonegap/phonegap-plugin-barcodescanner. They have a demo you can refer to: https://github.com/wildabeast/BarcodeDemo

Third party plugins will not work on the emulator or app preview. Please build the app. 

0 Kudos
Tony_D_1
Beginner
721 Views

Hi Anusha,

Thank you for getting back to me so quickly.

I followed your advice above and went to the demo, unfortunately it is the same as the cordova plugin registry, so doesn't give me any additional help.  I am able to import the plugin successfully as per your documentation and already know how to do the build for my app which I have done successfully using core plugins and everything else that goes with it (the documentation for your core plugins is really good and helpful).

I am really not sure what you mean by calling the plugin methods in my project.  Do I call java methods directly or do I call JavaScript functions?  I still do not know how to do this in my own code, that is what I have been trying unsuccessfully to do.  I would really appreciate an example as the one given in the documentation does not work.

I have tried to do a build with the imported plugin and am getting the following error at build.  I called my plugin "AscertScanner".

                     

  • Error: Plugin "AscertScanner" failed to install.

I would be grateful for any additional help you can give me.  Perhaps if you could point me to someone in the forums, who has built an app using this plugin or perhaps someone who can give me a worked example.  

I will repay this by doing a fully worked video example myself for future reference for others having difficulty here.

I do expect my problems are caused by my own inexperience, as I am a recent graduate and new to coding for real!  So any help would be appreciated.

 

 

 

 

0 Kudos
Amrita_C_Intel
Employee
721 Views

Hello,

Calling the plugin methods in your project means after importing plugin you need to make use of that plugin by calling the methods which comes along with imported plugin.

For example if you want to get these kinds of functionalities you need to use these built in methods.

 

Encoding a Barcode

The plugin creates the object cordova.plugins.barcodeScanner with the method encode(type, data, success, fail).

Supported encoding types:

  • TEXT_TYPE
  • EMAIL_TYPE
  • PHONE_TYPE
  • SMS_TYPE
A full example could be:

   cordova.plugins.barcodeScanner.encode(cordova.plugins.barcodeScanner.Encode.TEXT_TYPE, "http://www.nytimes.com", function(success) {
            alert("encode success: " + success);
          }, function(fail) {
            alert("encoding failed: " + fail);
          }
        );

Like wise there are many methods which you can use according to your requirements of the app.

0 Kudos
Tony_D_1
Beginner
721 Views

Hi Amrita C,

I am very sorry, I hope you do not think me rude, but you are not answering my questions.  All you are doing is re-hashing what is in the documentation that I have already said I do not understand and is not working.  

I cannot start to test out what you are telling me to do as intel xdk keeps bringing up an error when I do a build.  This is the error I am getting.

              

  • Error: Plugin "AscertScanner" failed to install.

This is the only information I get.  It doesn't tell me why it hasn't installed, which is really quite poor.

As I explained it is not at all clear from your documentation or the documentation from the plugin developer how it should be used.  Add to that the problems with intel xdk not completing the build when I have done everything correctly as per your documentation then I am sure you understand my frustration.

I would be very grateful if you would pass this problem onto someone who can actually help me.  At this stage I am considering moving to another platform as I cannot let let Intel XDK hold me back in the development of my app.  

 

0 Kudos
Anusha_M_Intel1
Employee
721 Views

Hi Tony, I am closing this one as it looks like you have made a repeat post. Please refer to my answer there. 

0 Kudos
Xavier_P_1
Beginner
721 Views

i have added the phonegap-plugin-barcodescanner plugin to my project and have come across the following issue. 
Error message "Uncaught TypeError: Cannot read property 'plugins' of undefined script" after calling the function from a button click. the alert message is displayed however the program terminates on the barcode scanner function. Please help

Intel XDK: 3618

BarcodeScanner Version 4.10

        function ScanItem(){
            alert("Scan Inventory Item now please hold");
          cordova.plugins.barcodeScanner.scan(
                  function (result) {
                      alert("We got a barcode\n" +
                            "Result: " + result.text + "\n" +
                            "Format: " + result.format + "\n" +
                            "Cancelled: " + result.cancelled);
                  },
                  function (error) {
                      alert("Failed to scan item Please try again: " + error);
                  },
                  {
                      "preferFrontCamera" : true, // iOS and Android 
                      "showFlipCameraButton" : true, // iOS and Android 
                      "prompt" : "Place a barcode inside the scan area", // supported on Android only 
                      "formats" : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED 
                      "orientation" : "landscape" // Android only (portrait|landscape), default unset so it rotates with the device 
                  }
               ); 
           
        }

0 Kudos
Giselle_G_Intel
Employee
721 Views

Xavier- 

Could you provide some more information about your error:

Does it specify a line? How do you know it terminates in this function? And finally, have you gone through the debugger to walk through the program?

0 Kudos
Reply