PhoneGap Beginner's Guide


PhoneGap Beginner's Guide
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.95
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$67.94
save 6%!
Packt
Anytime, Anywhere
Unlimited eBook downloads and up to 50% off the print version!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Learn how to use the PhoneGap mobile application framework
  • Develop cross-platform code for iOS, Android, BlackBerry, and more
  • Write robust and extensible JavaScript code
  • Master new HTML5 and CSS3 APIs
  • Full of practical tutorials to get you writing code right away

Book Details

Language : English
Paperback : 328 pages [ 235mm x 191mm ]
Release Date : September 2011
ISBN : 1849515360
ISBN 13 : 9781849515368
Author(s) : Andrew Lunny
Topics and Technologies : All Books, Mobile Application Development, Mobile, Beginner's Guides, Games

Table of Contents

Preface
Chapter 1: Installing PhoneGap
Chapter 2: Building and Debugging on Multiple Platforms
Chapter 3: Mobile Web to Mobile Applications
Chapter 4: Managing a Cross-Platform Codebase
Chapter 5: HTML5 APIs and Mobile JavaScript
Chapter 6: CSS3: Transitions, Transforms, and Animation
Chapter 7: Accessing Device Sensors with PhoneGap
Chapter 8: Accessing Camera Data and Files
Chapter 9: Reading and Writing to Contacts
Chapter 10: PhoneGap Plugins
Chapter 11: Working Offline: Sync and Caching
Appendix A: Deploying to iOS
Appendix B: Pop Quiz Answers
Index
  • Chapter 1: Installing PhoneGap
    • Operating systems
    • Dependencies
    • Getting started with iOS
    • Time for action – Getting an app running on the simulator
    • Installing PhoneGap-iPhone
    • Time for action – Hello World with PhoneGap-iPhone
    • Getting started with Android
      • A note on development environments
    • Time for action – Getting the SDK running
      • PhoneGap Android
    • Time for action – Hello World on PhoneGap Android
      • What's in a PhoneGap Android application, anyway?
  • Getting started with BlackBerry web works
  • Time for action – Your first PhoneGap BlackBerry app
    • Code signing for BlackBerry
  • Summary
    • Chapter 2: Building and Debugging on Multiple Platforms
      • Designing with desktop browsers
        • WebKit
      • Developing our first application: You Are The Best
      • Time for action – Initial design and functionality
        • Our workflow
        • Our styles
          • Unobtrusiveness
          • Width and height
          • -webkit-border-radius
        • Our scripts
          • Unobtrusiveness
          • addEventListener
          • DOMContentLoaded
      • Using the web inspector
        • Accessing web inspector
      • Time for action – Simple logging and error checking
      • Moving to native platforms
      • Time for action – You Are The Best for iPhone
        • <meta name="viewport">
        • phonegap.js
        • deviceready
      • Summary
      • Chapter 3: Mobile Web to Mobile Applications
        • Implementing web server roles
        • Time for action – Implementing LocalStorage
          • Other storage options
            • Web SQL
            • Indexed DB
        • View templating
        • Time for action – Food detail view
          • Accessing remote resources
            • Cross-origin policy
        • Time for action – Talking about food
          • Accessing remote resources
            • Parsing remote data
            • Event delegation
            • Sleight: The PhoneGap development server
        • Summary
        • Chapter 4: Managing a Cross-Platform Codebase
          • Inherent differences between platforms
            • Using a single codebase
          • Time for action - Detection and fallbacks
            • User agent sniffing
            • Feature detection
            • Media queries
            • Preprocessing code
          • Summary
          • Chapter 5: HTML5 APIs and Mobile JavaScript
            • Mobile JavaScript
              • XUI
            • Time for action – Downloading, building, and using XUI
              • Why not jQuery?
            • HTML5
              • Media elements
            • Time for action – My dinner with PhoneGap
              • Media events and attributes
              • The audio element
            • The canvas element
          • Time for action: Dinner dashboard
            • The canvas API
            • A note on performance
            • What else is in HTML5?
          • Summary
            • Chapter 6: CSS3: Transitions, Transforms, and Animation
              • Translate with transitions
              • Time for action – The modal tweet view
                • Timing functions
                • Other transformations
              • Scrolling
                • Viewports: Visual and otherwise
                • iScroll
              • Time for action – Scrolling list of food
                • Other approaches
              • Explicit animations
              • Time for action – Animating our headline
                • Animations: CSS3 or HTML5?
              • Summary
              • Chapter 7: Accessing Device Sensors with PhoneGap
                • What are device sensors?
                • Time for action – A postcard writer
                  • PhoneGap versus HTML5
                  • Other geolocation data
                • Accelerometer data
                • Time for action – Detecting shakes
                  • Device orientation and device motion events
                • Orientation media queries
                • Time for action – Landscape postcards
                  • Other media queries
                  • Magnetometer: The missing API
                • Summary
                • What about when we finally get an image?
                • Time for action – Getting a file path to display
                  • Where is this image, anyway?
                • Raw image data
                • Time for action – Saving pictures
                  • Ensure quality is set
                • Editing or accessing live data
                • Summary
                  • Time for action – Making friends
                    • What if I encounter a new problem?
                    • ContactFields, ContactName, and similar objects
                    • Be responsible
                  • Summary
                    • Time for action – Integrating ChildBrowser
                      • Differences between platforms
                      • Plugin discovery
                    • Writing a PhoneGap plugin
                    • Time for action – Battery view
                      • Noteworthy information about the PhoneGap plugin with iOS
                    • Porting your plugin
                    • Time for action – Android and BlackBerry
                      • Do you need cross-platform plugins?
                      • No limits
                    • Summary
                      • Time for action – A news site, with an API
                        • Alternatives to Sinatra
                      • Caching new stories
                      • Time for action – Caching stories in a local database
                        • Managing application initialization
                      • Summary
                          • Appendix B: Pop Quiz Answers
                            • Chapter 1
                              • PhoneGap iPhone Basics Answers
                            • Chapter 2
                              • Initial Design Answers
                            • Chapter 3
                              • Templating with Mustache Answers
                            • Chapter 4
                              • Feature Detection vs UA Sniffing Answers
                            • Chapter 5
                              • XUI Answers
                              • Media Elements Pop Quiz Answers
                            • Chapter 6
                              • Scrolling Answers
                            • Chapter 7
                              • Geolocation Answers
                              • Orientation and Media Queries Answers
                            • Chapter 8
                              • navigator.camera.getPicture Answers
                              • Destination Types Answers
                            • Chapter 9
                              • Contacts Answers
                            • Chapter 10
                              • Using PhoneGap Plugins Answers
                              • Writing PhoneGap Plugins Answers
                            • Chapter 11
                              • A Simple Web Service Answers

                            Andrew Lunny

                            Andrew Lunny is a programmer at Nitobi Software Inc in Vancouver, British Columbia. He has worked with the PhoneGap team since the project's inception, and currently works on the PhoneGap Build web service for building PhoneGap applications in the cloud.
                            Sorry, we don't have any reviews for this title yet.

                            Code Downloads

                            Download the code and support files for this book.


                            Submit Errata

                            Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                            Errata

                            - 9 submitted: last submission 08 Nov 2012

                            Errata type: Grammar| Page number: 66

                            "It is not a JavaScript array the object is an instance of the native Storage class which doesn't have constructor access to from inside the browser environment but it has array-like features, such as a length property."

                            should be

                            "It is not a JavaScript array—the object is an instance of the native Storage class which doesn't have constructor access to from inside the browser environment—but it has array-like features, such as a length property."

                             

                            Errata type: Code|Page number:88 | Errata received on 01-04-2012

                            In the book appears the following command:

                            $ npm install –g sleight

                            it should be:

                            $ npm install sleight -g

                            (tested in win7 with nodejs0.6.14)

                            Errata type: Code|Page :62 ,Step 2 | Errata recieved on 03-03-2012

                            In the book the fthe HTML code appears as:

                            ...

                            <div id=»main»>
                            <h1>List Some Food</h1>
                            <form id=»foodForm»>
                            <input type=»text» id=»foodName» placeholder=»A name of
                            a food» />
                            <button id=»submitFood»>Tell Us!</button><br>

                            ....

                             

                            The » should be quotes (") , like this:

                            ...

                            <div id=»main»>
                            <h1>List Some Food</h1>
                            <form id="foodForm">
                            <input type="text" id="foodName" placeholder="A name of
                            a food" />
                            <button id="submitFood">Tell Us!</button><br>

                            ...

                             

                            Errata type: Code|Page :49 ,Step 5  | Errata received on 29-03-2012

                            The code snippet in the book is as follows:

                            function alertCompliment() {
                            console.log("alertCompliment() called")
                            var elementId = this.id, 
                            var greeting;

                             

                            It should have been:

                            function alertCompliment() {
                            console.log("alertCompliment() called")
                            var elementId = this.id; 
                            var greeting;

                            Errata type: Code|Page :48 ,Step 3  | Errata received on 29-03-2012

                            The code in this step, in the book is as follows:

                            function alertCompliment() {
                            var elementId = this.id,
                            var greeting;

                            ...

                            It should be as follows:

                            function alertCompliment() {
                            var elementId = this.id;
                            var greeting;

                            ...

                             

                             

                            Errata type: Technical|Page :12-15  | Errata received on 03-04-2012

                            Erratta:the git-URLs are not valid

                             

                            Solution:
                            new git command to get the code from Apache Incubator:
                            git clone https://git-wip-us.apache.org/repos/asf/incubator-cordova-ios.git

                            Errata type: Technical|Page :12-15  | Errata received on 24-01-2012

                            Erratta:
                            The cd to incubator-cordova-ios the directory, and the make command worked properly, so everything builds.

                            But ...

                            PhoneGapLibInstaller.pkg isn't generated directly.

                             

                            Solution:

                            Create a PhoneGap project (Xcode 4)
                            -------------------------------------------------------------

                            1. Launch Xcode, then under the File menu, select "New Project...".
                            2. Navigate to the "iOS" section, under "Applications" - then in the right pane, select "PhoneGap-based Application"
                            3. Select the "Next" button, name your project and company idenfifier, then select the "Next" button again.
                            4. Choose the location where you want the new project to be.
                            5. Run the project at least once to create the "www" folder in your project folder.
                            6. Drag and drop this "www" folder into your project in Xcode, and add it as a folder reference.
                            7. Modify the contents of the "www" directory to add your HTML, CSS and Javascript.

                            Errata type: Code|many pages | Errata received on 07-01-2012

                            Errata: A large number of code sections in book have quotes replaced with guillemets (« or »).

                            Solution:

                            The gullements are mostly in code, the gulliments (« or ») are to b ereplace with quotes (")

                             

                            Errata type: Typo|Page:2 | Errata received on 04-10-2012

                            In the last sentence on the page:"or on mobile applicatons. No experience with natve mobile SyDKs is required."

                             

                            It should have been:"or on mobile applicatons. No experience with natve mobile SDKs is required."

                            Sample chapters

                            You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                            Frequently bought together

                            PhoneGap Beginner's Guide +    Web Content Management with Documentum =
                            50% Off
                            the second eBook
                            Price for both: $36.00

                            Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                            What you will learn from this book

                            • Rich interactions using HTML5 and CSS3 APIs
                            • Mobile JavaScript expertise: write code that travels anywhere
                            • Working offline: use web development skills with native code to create installable web-apps that sync with remote servers
                            • Enhancing application experiences with real-time sensor data
                            • Integrating with cameras and images to enrich users' experiences
                            • Access device contacts and data for fully native interactions
                            • Detecting devices precisely and skillfully to progressively enhance your user interface within a single application
                            • Pluging in to PhoneGap: adding functionality to the framework with custom native code

                            In Detail

                            With the increasingly fragmented mobile application landscape, it's important to find strategies that allow for rapid development on many different platforms. Using PhoneGap, you will be able to use a single codebase that targets iOS, Android, BlackBerry, and more, just using web development skills.

                            PhoneGap  Beginner's Guide will show you how to use the PhoneGap mobile development framework to target multiple mobile platforms: iOS, Android, BlackBerry, and more with a single application. With PhoneGap, you can use existing web development skills, instead of learning a new environment for every platform on the market.

                            PhoneGap Beginner's Guide will escalate you from being a novice at mobile development to writing complex applications that target multiple platforms, through learning the APIs and development process of the PhoneGap framework.

                            You will learn how to manage a code base that targets multiple mobile platforms; how to use new HTML5 and CSS3 APIs to create rich, responsive user interfaces; and how to use the PhoneGap APIs to integrate with native functionality such as device sensors, contacts, and cameras.

                            After reading PhoneGap Beginner's Guide, you will have the skills and the confidence to target all of the major mobile platforms with rich and responsive applications.

                            This is a beginner's introduction to practical use of the PhoneGap mobile application framework.

                            Approach

                            This is a step-by-step guide written in an informal, friendly style, for beginners to learn building cross-platform mobile applications with PhoneGap. You will find plenty of fully explained code and ample screenshots in the book to ease and speed up your understanding.

                            Who this book is for

                            This book is for developers, ideally with web development experience, who are interested in developing for the emerging mobile market, but do not want to learn a new SDK for every phone on the shelf. Readers should be comfortable with JavaScript, HTML, and CSS, and interested in learning the new advances in those technologies that allow for rich, native-style experiences.

                            Code Download and Errata
                            Packt Anytime, Anywhere
                            Register Books
                            Print Upgrades
                            eBook Downloads
                            Video Support
                            Contact Us
                            Awards Voting Nominations Previous Winners
                            Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                            Resources
                            Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software