Book Image

PhoneGap Beginners Guide (third edition)

Book Image

PhoneGap Beginners Guide (third edition)

Overview of this book

Table of Contents (22 chapters)
PhoneGap Beginner's Guide Third Edition
About the Authors
About the Reviewers
Related Plugin Resources


PhoneGap Beginner's Guide Third Edition will help you break into the world of mobile application development. You will learn how to set up and configure your mobile development environment, implement the most common features of modern mobile apps, and build rich, native-style experiences. All the examples deal with real use case scenarios covering the functionality of various plugins.

What this book covers

Chapter 1, Introduction to PhoneGap, covers how to set up dependencies and mobile platform SDKs in your development environment.

Chapter 2, Building Your First PhoneGap Project, deals with PhoneGap internals, project structure, and using CLI tools.

Chapter 3, Mobile Frameworks, gives an introduction to various mobile frameworks and sample projects using jQuery Mobile.

Chapter 4, Working with Plugins, covers information about PhoneGap plugins and using them in the application.

Chapter 5, Using Device Storage and the Files API, deals with offline data storage capabilities and the Files plugin.

Chapter 6, Using the Contacts and Camera APIs, covers how to implement the Contacts API and how to interact with the device camera by using the Camera API.

Chapter 7, Accessing the Device Sensors and Locations API, deals with using device sensors and the Locations API and their power and limitations with respect to the plugins provided by PhoneGap.

Chapter 8, Advanced PhoneGap, covers some advanced topics such as adding multilanguage and touch gesture support to your application.

Chapter 9, Getting Ready for Release, helps you understand how to make your application ready for public release in various application stores.

Chapter 10, A Sample PhoneGap Project, deals with the development of a full-fledged PhoneGap application from scratch, using the most common PhoneGap plugins.

Appendix A, The JavaScript Quick Cheat Sheet, is a mini cheat sheet for commonly used JavaScript methods and properties.

Appendix B, Publishing Your App, describes how you can publish your apps on different app stores.

Appendix C, Related Plugin Resources, is a list of some related plugins that can be used with PhoneGap.

Appendix D, PhoneGap Tools, describes tools that will help you to debug and test your applications without any difficulties.

What you need for this book

A personal computer with an Internet connection and the default command-line tool to use with the command-line utilities distributed with PhoneGap. OS X and Linux users just need the default command-line tool.

Who this book is for

This book is for web developers who want to be productive in the mobile market quickly. In fact, by using PhoneGap, it's possible to deploy native applications based on web standards. This book assumes a very small knowledge of HTML/CSS/JavaScript and mobile platforms, such as Android, BlackBerry, iOS, and Windows Phone, and takes the reader step-by-step into a deep overview of PhoneGap and its APIs.


In this book, you will find several headings that appear frequently (Time for action, What just happened?, Pop quiz, and Have a go hero).

To give clear instructions on how to complete a procedure or task, we use these sections as follows:

Time for action – heading

  1. Action 1

  2. Action 2

  3. Action 3

Instructions often need some extra explanation to ensure they make sense, so they are followed with these sections:

What just happened?

This section explains the working of the tasks or instructions that you have just completed.

You will also find some other learning aids in the book, for example:

Pop quiz – heading

These are short multiple-choice questions intended to help you test your own understanding.

Have a go hero – heading

These are practical challenges that give you ideas to experiment with what you have learned.


You will also find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "You may notice that we used the Unix command rm to remove the Drush directory rather than the DOS del command."

A block of code is set as follows:

document.addEventListener("deviceready", function() {
    // Application starts here

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

reader.onload = function(evt){

    var img = document.querySelector('#firstImage');
    img.src =;


Any command-line input or output is written as follows:

C:\example1> phonegap prepare android

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "See the results in the console by clicking on the Run button at the bottom right of the panel."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.