O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

PhoneGap Essentials

Book Description

Use PhoneGap to build cross-platform mobile applications quickly and efficiently

About This Book

  • Build native mobile phone applications with HTML5, JavaScript, and CSS
  • Incorporate smartphone capabilities such as GPS, camera, accelerometer, and more into your apps for any mobile platform
  • Use Cordova view to embed PhoneGap into native applications to either transit smoothly to PhoneGap or incorporate PhoneGap functionalities

Who This Book Is For

If you are a mobile application developer in iOS or Android, or a web application developer who wants to learn how to make cross-platform mobile applications using PhoneGap, this book is perfect for you. To make the most of this book, it will be helpful if you have prior knowledge of HTML5, CSS, and JavaScript.

What You Will Learn

  • Get to grips with the fundamentals of PhoneGap to get started
  • Set up a development environment for Linux, Mac OS, and Windows
  • Use Cordova CLI, workflows, and Plugman Plugin manager to create mobile applications efficiently
  • Understand the development workflow to create native cross-platform mobile applications
  • Embed plugin support to transition to PhoneGap or use it to enhance existing applications
  • Improve your mobile development knowledge using object-oriented programming (OOP), reusable components, and AJAX closures
  • Be empowered to build your own mobile apps quickly with ease
  • Discover tips and tricks to make app development fun and easy

In Detail

PhoneGap is an open source framework that allows you to quickly build cross-platform mobile apps using HTML5, JavaScript, and CSS. PhoneGap Build is a cloud service that allows you to quickly develop and compile mobile applications without SDKs, compilers, and hardware. PhoneGap allows you to use its existing plugins or create new ones, as per your requirements, to enhance your mobile applications.

Starting by installing PhoneGap, you’ll develop an app that uses various device capabilities through different plugins and learn how to build an app in the cloud with PhoneGap’s Build service.

You’ll discover how to use PhoneGap to create an application view, along with how to use a camera, geolocation, and other device capabilities to create engaging apps. Next, you’ll augment applications with PhoneGap's plugins using minimalistic code. You’ll explore the app preparation process to deploy your app to the app store.

By the end of the book, you’ll have also learned how to apply hybrid mobile UIs that will work across different platforms and different screen sizes for better user experience.

Style and approach

This is an example-based, fast-paced guide that covers the fundamentals of creating cross-platform mobile applications with PhoneGap.

Downloading the example code for this book. 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.

Table of Contents

  1. PhoneGap Essentials
    1. Table of Contents
    2. PhoneGap Essentials
    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. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Get up and Running with PhoneGap
      1. A brief history
      2. What is PhoneGap?
        1. Where can it be used?
        2. What PhoneGap is not
        3. Competition
        4. PhoneGap or Cordova?
      3. Setting up a local development environment
        1. Mac OS
        2. Linux
        3. Windows
      4. Summary
    9. 2. Mobile Platform Support
      1. Supported platforms
        1. Supported features by platform
        2. Support for development
      2. PhoneGap Build
        1. Platform support
        2. Using PhoneGap Build
      3. The PhoneGap Developer App
        1. How to use it
      4. Summary
    10. 3. Command-line Interface
      1. Introduction to a command-line interface
        1. PhoneGap CLI versus Cordova CLI
        2. Installing the PhoneGap CLI
      2. Creating a new project
        1. Creating a Hello project
        2. Creating a new project
        3. Managing platforms
          1. Adding a platform
          2. Listing platforms
          3. Removing a platform
          4. Keeping platforms up-to-date
          5. Application description
        4. Creating a project from a template
      3. Managing the project
        1. Application preview
        2. Preparing an application
        3. Compiling an application
        4. Building an application
        5. Running an application
        6. Emulating an application
      4. Using PhoneGap Build
        1. Authentication
        2. Preparing the application
        3. Building the application
      5. Summary
    11. 4. Plugin Support
      1. Introducing plugins
        1. What is a plugin?
        2. Support for different mobile platforms
        3. Installing plugins
        4. Command-line Interface
        5. Finding plugins
        6. Adding plugins
        7. Listing plugins
        8. Removing plugins
      2. Plugman
        1. Installing Plugman
        2. Searching for plugins
        3. Installing plugins
        4. Removing plugins
      3. npm
      4. Plugins
        1. Battery Status
        2. Camera
        3. Contacts
        4. Device
        5. The Device Motion plugin
        6. Device position orientation
        7. Dialogs
        8. FileSystem
        9. File Transfer
        10. Geolocation
        11. Globalization
        12. InAppBrowser
        13. Media
        14. Media Capture
        15. Network Information
        16. Splashscreen
        17. Vibration
        18. StatusBar
      5. Summary
    12. 5. First PhoneGap Application
      1. Starting a new application
        1. Creating a new application
        2. Setting up the initial code
      2. Project folder structure
      3. Core PhoneGap events
        1. The deviceready event
        2. The pause event
        3. The resume event
      4. Essential plugins
        1. The Device plugin
        2. The Network Information plugin
        3. The StatusBar plugin
        4. The Dialogs plugin
      5. Summary
    13. 6. Accessing Native APIs
      1. Native APIs
        1. Device status plugins
        2. Motion sensing plugins
        3. Media functionality plugins
        4. Notification plugins
      2. The Battery Status plugin
        1. The Battery Status event
        2. The Low Battery event
        3. The Critical Battery event
      3. The Device Motion plugin
        1. The getCurrentAcceleration method
        2. watchAcceleration
        3. clearWatch
      4. The Device Orientation plugin
        1. getCurrentHeading
        2. watchHeading
        3. clearWatch
      5. The Geolocation plugin
        1. getCurrentPosition
        2. watchPosition
        3. clearWatch
        4. The Position object
          1. The Coordinates object
      6. The Vibration plugin
        1. Vibrate
          1. Standard vibrate
        2. Vibrating with a pattern (Android and Windows only)
          1. Cancelling the vibration (not supported in iOS)
      7. Summary
    14. 7. Accessing Media Content
      1. Introducing multimedia
        1. Media
        2. File management
        3. Contacts
      2. File Transfer
        1. The FileTransfer object
        2. The FileUploadResult object
        3. Upload
        4. Download
        5. Abort
      3. Contacts
        1. Contact
          1. The Contact object
          2. ContactName
          3. ContactField
          4. ContactAddress
          5. ContactOrganization
        2. The create method
        3. Find
        4. pickContact
      4. Camera
        1. getPicture
        2. cleanup
      5. InAppBrowser
        1. The InAppBrowser object
        2. The InAppBrowserEvent object
        3. Open
      6. Summary
    15. 8. Application Development Workflow
      1. An introduction to a development workflow
        1. Web project development
        2. Native platform development
      2. Best practices
      3. Use local assets for the UI
        1. Network access for data
        2. Non-blocking UI
        3. CSS animations
        4. Click events
        5. Performance
        6. Optimize the image assets
        7. Offline status
        8. Load only what you need
        9. Transparency
        10. JSHint
      4. Testing
      5. Debugging
        1. Desktop browsers
        2. The PhoneGap emulator
        3. Weinre
        4. iOS Debugging
          1. Xcode
          2. Safari Remote Debugging
        5. Android debugging
      6. User interface
      7. Summary
    16. Index