Appendix D

PhoneGap Plug-ins

An entire community of developers has started creating plug-ins for PhoneGap on Android and iOS device platforms. (There are currently no plug-ins yet for Palm and BlackBerry.) The idea behind a plug-in is simple: Create native and JavaScript code solutions that other developers can “plug in” to their projects and, thus, quickly and easily extend PhoneGap’s capabilities.

Currently, all PhoneGap plug-ins are hosted at https://github.com/phonegap/phonegap-plugins, which is shown in Figure D-1.

FIGURE D-1: Site where PhoneGap plug-ins are hosted

image

This appendix summarizes each of the available plug-ins for each platform.

ANDROID PLUG-INS

The following plug-ins are available for Android:

  • Analytics
  • BarcodeScanner
  • BlueTooth
  • ChildBrowser
  • ClipboardManager
  • ContactView
  • FileUploader
  • FtpClient
  • PayPalPlugin
  • PowerManagement
  • Share
  • SoftKeyboard
  • StatusBarNotification
  • TTS
  • WebIntent

Analytics

Use this plug-in to integrate Google analytics with your Android app. It creates a window.plugins.analytics object.

To start, enter the following code:

/**
 * Initialize Google Analytics configuration
 * 
 * @param accountId         The Google Analytics account id 
 * @param successCallback   The success callback
 * @param failureCallback   The error callback
 */
   
  start(accountId, successCallback, failureCallback);

To track a page view, use the following code:

/** * Track a page view on Google Analytics ...

Get Beginning PhoneGap now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.