Source language: Translate to:

Converting Phonegap Plugins

Questions, announcements and information regarding PlugIns for NeoAppBuilder

Moderator: Neosoft Support

Converting Phonegap Plugins

Postby jsjohnstone » Mon Apr 25, 2016 7:11 pm

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
jsjohnstone
 
Posts: 2
Joined: Sun Jun 17, 2012 2:13 am

Re: Converting Phonegap Plugins

Postby Neosoft Support » Tue Apr 26, 2016 6:16 pm

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

Re: Converting Phonegap Plugins

Postby TinTin » Mon Jun 20, 2016 11:54 am

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");
}
});
TinTin
 
Posts: 162
Joined: Sun Dec 06, 2009 4:03 am
Location: UK

Re: Converting Phonegap Plugins

Postby Neosoft Support » Sun Jun 26, 2016 12:44 pm

Could you use the BeginJS..EndJS actions?

For example:

BeginJS

your javascript code goes here...

EndJS
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5602
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA


Return to NeoAppBuilder PlugIns

Who is online

Users browsing this forum: No registered users and 1 guest

cron