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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.