Page 1 of 1

Converting Phonegap Plugins

PostPosted: Mon Apr 25, 2016 7:11 pm
by jsjohnstone
Hi there,

I'm just getting started with NeoAppBuilder and absolutely loving it - great product.

I've found the "Plugin Builder" hidden away in the Tools menu, and am assuming this can be used to add Phonegap plugins (or other plugins) - would that be correct?

If I wanted to add a standard Phonegap Plugin - for example, the Barcode Scanner (https://github.com/phonegap/phonegap-pl ... odescanner) - how would I use the Plugin Builder to add the two actions it requires (cordova.plugins.barcodeScanner.scan and cordova.plugins.barcodeScanner.encode) and get parameters back?

As an example, the scan action in javascript is:

Code: Select all
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("Scanning failed: " + error);
      }
   );


If someone could please advise how to do this, I'll be able to work out how to build future plugins also :)


Thanks,

James

Re: Converting Phonegap Plugins

PostPosted: Tue Apr 26, 2016 6:16 pm
by Neosoft Support
Hi James,

Welcome to NeoAppBuilder!

NAB's Plugin Generator is still under construction, so it may need some tweaking to get it to work properly with PhoneGap plugins. For example, you may need to manually add the PhoneGap plugin to the app's manifest in order for it to work.

I looked at the barcode scanner link, but I didn't see any samples that might show us how it works within context of a working PhoneGap app.

Re: Converting Phonegap Plugins

PostPosted: Mon Jun 20, 2016 11:54 am
by TinTin
I too am interested in adding some phonegap plugins to an app.. the addition of the plugin to the config.xml is straight forward however how would one add to a JS block, for instance the flashlight function?


window.plugins.flashlight.available(function(isAvailable) {
if (isAvailable) {

// switch on
window.plugins.flashlight.switchOn(); // success/error callbacks may be passed

// switch off after 3 seconds
setTimeout(function() {
window.plugins.flashlight.switchOff(); // success/error callbacks may be passed
}, 3000);

} else {
alert("Flashlight not available on this device");
}
});

Re: Converting Phonegap Plugins

PostPosted: Sun Jun 26, 2016 12:44 pm
by Neosoft Support
Could you use the BeginJS..EndJS actions?

For example:

BeginJS

your javascript code goes here...

EndJS