Menu

Installing Cordova Plugins

Currently the process for installing Cordova Plugins contains a number of manual steps. Eventually we would like to improve this with tooling.

Android

Snippet 1

private static final String HTML_TEMPLATE_FORMAT_STRING = "<html><head><script src='cordova.js'></script><script src='cordova_plugins.js'></script><script src='%s'></script></head></html>";

Snippet 2

// Poor man's Cordova plugin initialization.
CordovaPlugin plugin = new BarcodeScanner();
PluginEntry entry = new PluginEntry("BarcodeScanner", plugin);
cordovaPluginEntries = new ArrayList<PluginEntry>();
cordovaPluginEntries.add(entry);

iOS

Plugin Caveats & Compatibility

Cordova plugins vary in quality and implementation. Some are more compatible with Astro than others. Any non-UI based plugin should be 100% compatible. Plugins that present a UI should work correctly if they present their own UIViewController (using viewController.presentViewController(customPluginViewController)).

Some plugins manually integrate UIViews into the view hierarchy using self.webView.superview.addSubview(). These plugins will not work because the UIWebView that hosts the Cordova javascript (as well as the Astro app.js) is never visible. These plugins would need to be changed to use presentViewController() before they work.

The behaviour you'll get if you instantiate multiple instances of the same plugin from different web views is undefined. Some plugins that present their own UI (as discussed above) may work but may supercede the other web view's plugin UI. In other cases they may conflict and cause errors. Generally we recommend only using Cordova plugins from app.js.