You are previewing PhoneGap.
O'Reilly logo
PhoneGap

Book Description

Build cross-platform mobile applications with the PhoneGap open source development framework with this book and eBook

  • 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

  • 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.

    Table of Contents

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