Over a million developers have joined DZone.

Phonegap 3.0 Released

DZone 's Guide to

Phonegap 3.0 Released

· Mobile Zone ·
Free Resource

Today at PhoneGap Day version 3.0 was released. This is a pretty significant release in terms of the underlying architecture and there are some things you should know.

First - let's start with a few links you should read:

Adobe PhoneGap 3.0 Released
What's New in Cordova iOS 3
Introducing Cordova 3 for Android

Second - there is a new command line tool you will use (or can use I should say, the cordova-cli still works), phonegap. The installation for this is rather trivial if you've got npm already installed:

 sudo npm install -g phonegap

This may seem obvious, but phonegap cli is different from cordova cli. Be sure to use the built-in help and sniff around a bit so you see how it does things compared to cordova. This shouldn't take more than a few minutes and you will probably trip up a few times. Thank you, muscle memory.

One of the coolest aspects of the new command line though is that it fully supports PhoneGap Build. What this means is that you can use the command line to builds via your terminal with and without the SDKs. Or heck, even if you do have the SDKs and want to use PhoneGap Build, the new PhoneGap cli makes this trivial.

Another useful feature is that if you run phongap as is, you get a quick checklist of what SDKs/platforms you can use locally:


This is the number one thing that I think will trip people up. One of the new things in PhoneGap 3 is a revised plugin architecture. All of the previously core features, like the Camera for example, are plugin based.

When I realized this, my first question was whether a virgin project would include support for the core stuff and expect developers to strip things out (if they cared) or if you would need to implicitly add in support for what you want to use.

Turns out - you need to add in what you want to use. What does that mean practically? As an example, if you try to use navigator.camera.getPicture it will fail with the "out of the box" project made at the command line.

To fix this you can add in the plugin of course. This takes two seconds and can be done via the CLI. This may not be very clear via the docs. First, the command line docs do talk about the core features as plugins and give you the commands to use... but for cordova, not phonegap.

So as an example, this is the cordova way to add the plugin: cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git

And this is how you would do it via phonegap: phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git

The net result is that when you start your PhoneGap project, you will want to think ahead of time about the features you need - the previously "just there" features - and add them via the CLI. (As an FYI, it is super easy to remove these plugins too. So if you added the Camera and realize you don't need it, you can quickly remove it.)

For a full list of these plugins, see below. I copied this directly from the link above, so it may change, so please see the link for the most up to date version. And in case it isn't obvious, the $ means the command prompt, not jQuery. ;)

Basic device information:
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git

Network and battery status:
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information.git
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status.git

Accelerometer, compass, and geolocation:
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion.git 
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation.git
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git

Camera, media capture, and media playback:
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-media.git

Access files on device or network:
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git

Notifications via dialog box or vibration:
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration.git

$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts.git

$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization.git

Splash Screen:
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen.git

In-app browser:
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git

Debug console:
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git

p.s. I've not no idea what the plugin console is. Going to research.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}