Converting Phonegap Plugins

Questions, announcements and information regarding PlugIns for NeoAppBuilder

Moderator: Neosoft Support

Locked
jsjohnstone
Posts: 2
Joined: Sun Jun 17, 2012 2:13 am

Converting Phonegap Plugins

Post 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
Neosoft Support
NeoSoft Team
Posts: 5628
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA
Contact:

Re: Converting Phonegap Plugins

Post 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.
NeoSoft Support
TinTin
Posts: 164
Joined: Sun Dec 06, 2009 4:03 am
Location: UK

Re: Converting Phonegap Plugins

Post 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");
}
});
Neosoft Support
NeoSoft Team
Posts: 5628
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA
Contact:

Re: Converting Phonegap Plugins

Post by Neosoft Support »

Could you use the BeginJS..EndJS actions?

For example:

BeginJS

your javascript code goes here...

EndJS
NeoSoft Support
Locked