Book Image

PhoneGap 3 Beginner's Guide

By : Giorgio Natili
Book Image

PhoneGap 3 Beginner's Guide

By: Giorgio Natili

Overview of this book

<p>You don’t have to know complex languages like Objective C to compete in the ever-growing mobile market place. The PhoneGap framework lets you use your web development skills to build HTML and JavaScript-based mobile applications with native wrappers that run on all the major mobile platforms, including Android, iOS, and Windows Phone 8.</p> <p>"PhoneGap 3 Beginner's Guide" 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 applications. The examples in this book deal with real use case scenarios, which will help you develop your own apps, and then publish them on the most popular app stores.</p> <p>Dive deep into PhoneGap and refine your skills by learning how to build the main features of a real world app.</p> <p>"PhoneGap 3 Beginner's Guide" will guide you through the building blocks of a mobile application that lets users plan a trip and share their trip information. With the help of this app, you will learn how to work with key PhoneGap tools and APIs, extend the framework’s functionality with plug-ins, and integrate device features such as the camera, contacts, storage, and more. By the time you’re finished, you will have a solid understanding of the common challenges mobile app developers face, and you will know how to solve them.</p>
Table of Contents (22 chapters)
PhoneGap 3 Beginner's Guide
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

PhoneGap Beginner's Guide 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. Most of the samples deal with real use case scenarios, based upon the code of an open source application available through the most popular app stores.

What this book covers

Chapter 1, Getting Started with PhoneGap, covers how to set up dependencies and mobile SDKs in your development environment.

Chapter 2, Building and Debugging on Multiple Platforms, deals with choosing the development tool that best fits your needs and it will provide an overview of several tools and some debugging techniques.

Chapter 3, Getting Started with Mobile Applications, covers how to improve the performance of a mobile app. You will see how to define the building blocks of a modern hybrid app built using web standards and PhoneGap.

Chapter 4, Architecting Your Mobile App, deals with creating the backbones of your mobile app, focusing on the architecture of the app and on bootstrapping the app.

Chapter 5, Improving the User Interface and Device Interaction, deals with consolidating the app architecture, learning how to implement the navigation mechanics, and how to handle the user interface depending on the network status.

Chapter 6, Using Device Storage and the Contacts API, helps you to understand the offline storage capabilities of PhoneGap and how to interact with the Contacts API.

Chapter 7, Accessing Device Sensors, deals with introducing device sensors, and explaining their power and limitations with regard to the effective use of the APIs provided by the PhoneGap framework.

Chapter 8, Using Location Data with PhoneGap, covers how to get the Geolocation information from a device and how to integrate the external Geolocation service in your app.

Chapter 9, Manipulating Files, covers how to manipulate files on a device. With this knowledge you will be able to store information and read files on a device.

Chapter 10, Capturing and Manipulating Device Media, covers how to access the device camera and all the other capturing tools available in the device.

Chapter 11, Working with PhoneGap Plugins, covers how to extend the PhoneGap capabilities using native code. You will see how PhoneGap's apps architecture allows developers to extend the framework capabilities with the help of custom plugins.

Appendix A, Localizing Your App, covers how to create a localized app using PhoneGap. You will be introduced to the Globalization API, a very powerful tool that allows you to work in conjunction with other JavaScript libraries.

Appendix B, Publishing Your App, covers how you can publish your app on different app stores and discusses the common issues faced.

What you need for this book

A personal computer with an Internet connection and a command line tool to use with the command line utilities distributed with PhoneGap. Windows users should install Cygwin, available at http://www.cygwin.com/, to have a Linux look and feel environment; 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 start to be productive in the mobile market quickly. In fact by using PhoneGap it's possible to deploy native applications based upon web standards. The book assumes a very small knowledge of HTML/CSS/JavaScript and of 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 API.

Conventions

In this book, you will find several headings appearing frequently.

To give clear instructions of how to complete a procedure or task, we use:

Time for action – heading

  1. Action 1

  2. Action 2

  3. Action 3

Instructions often need some extra explanation so that they make sense, so they are followed with:

What just happened?

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

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

Pop quiz – heading

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

Have a go hero – heading

These practical challenges give you ideas for experimenting with what you have learned.

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

Code words in text are shown as follows: "The root folder contains the AndroidManifest.xml file; it's important that the package name and the activity name defined in the files match the arguments used when launching the ./create command"

A block of code is set as follows:

({
    baseUrl: 'js/',
    paths: {
        mustache: 'libs/mustache',
        alice: 'libs/alice.min',
        text: 'libs/require/plugins/text'
    },
    name: 'main',
    out: 'js/main-built.js'
})

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

function processImages(){

  var pixelRatio = window.devicePixelRatio;
  if(window.devicePixelRatio > 1) {
    var matches = document.querySelectorAll("img.highRes");
    for(var i = 0; i < matches.length; i++) {
      
      matches[i].width = (matches[i].width / pixelRatio);
    
    }
  }

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

$ cordova create ~/PhoneGapProjects/PGGettinStarted/ch06/storage SampleStorage

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: "On Mac the command-line tool is named Terminal and you can find it by navigating to Applications | Utilities | Terminal."

Note

Warnings or important notes appear in a box like this.

Tip

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 may have disliked. Reader feedback is important to us so we can develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title through 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 on www.packtpub.com/authors.

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.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

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 would 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 http://www.packtpub.com/submit-errata, selecting your book, clicking 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.

Piracy

Piracy of copyright 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.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.