DecSoft's App Builder

Index of ContentsCordova plugins

App Builder can't add every Apache Cordova plugin but help us to use any plugin we wanted.

Include Cordova custom plugins

Into the app options dialog we can found the Cordova tab and inside we can found a Custom plugin editbox. We can add here one or more Cordova plugin ID's, for example, suposing we want to use the Hazems's Cordova SMS plugin, we must add the ID "com.jsmobile.plugins.sms" (without quotes) into the Cordova Custom plugins editbox. Once we add the plugin ID in the Custom plugins editbox, App Builder builder generated Cordova Batch files and the generated "config.xml" for Cordova automatically include the right information in order to refer and install the plugin.

Use Cordova plugins Javascript

Once we include the appropiate reference for the plugin ID into the Custom plugin editbox (as described above) we need to refer to the plugin author in order to find the plugin Javascript reference. Such Javascript depends upon the plugin, but, suposing we want to use the SMS plugin refered above, we can add an Javascript app function with two arguments, "number" and "message", and this function body Javascript code:

var
  messageInfo =
  {
    phoneNumber: number,
    textMessage: message
  };

sms.sendMessage
(
  messageInfo,
  function(message) {
    alert('success');
  },
  function(error) {
    alert('Error: ' + error.message);
  }
);

That's all! The added function appear now into the Actions palette under the Function's category and, suposing we name the function like "SendSMS", we can use it in every app event in this way:

SendSMS "987654321" "Hello world!"

Last but not least, take a look at the "CordovaPlugins" app sample included by App Builder. This sample show us how use the refered Apache Cordova custom plugin in the above described way.