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

Apache Cordova 4 Programming

Book Description

Using Apache Cordova 4, you can leverage native technologies and web standards to quickly build cross-platform apps for most mobile devices. You can deliver a high-end user experience where it matters, while radically simplifying code maintenance and reuse. Apache Cordova 4 Programming is the most concise, accessible introduction to this remarkable technology.

In this essential guide, expert mobile developer John Wargo quickly gets you up to speed with all the essentials, from installation, configuration, and tools, to building plugins and using Cordova’s powerful APIs. Wargo helps you make the most of Cordova 4’s major enhancements, while offering practical guidance for all versions, including Adobe PhoneGap. Full chapters are dedicated to five major mobile platforms: Android, iOS, Windows Phone, Firefox OS, and Ubuntu.

Using rich, relevant examples, Wargo guides you through both the anatomy of a Cordova app and its entire lifecycle, including cross-platform testing and debugging. Throughout, he illuminates Cordova development best practices, streamlining your development process and helping you write high-quality apps right from the start.

Topics include

  • Installing and configuring Cordova’s development environment

  • Working with the Cordova command line interfaces

  • Creating Cordova plugins, using Plugman and the PhoneGap CLI

  • Cordova’s support for Firefox OS and Ubuntu devices

  • Automation (Grunt and Gulp) and Cordova CLI hooks

  • Microsoft’s hybrid toolkit for Visual Studio

  • Third-party tools, such as AppGyver, GapDebug, THyM, and more

  • Beautifying Cordova apps with third-party HTML frameworks, such as Bootstrap, OpenUI5, Ionic, and Onsen UI

  • Running, testing, and debugging Cordova apps on each major mobile platform 

  • Access the full code examples at cordova4programming.com, where you’ll also find updates reflecting Cordova’s continuing evolution.

    This book is an ideal companion to Wargo’s authoritative collection of Apache Cordova code recipes for each Cordova API, Apache Cordova API Cookbook (Addison-Wesley, 2015).

    Table of Contents

    1. About This eBook
    2. Title Page
    3. Copyright Page
    4. Dedication Page
    5. Contents
    6. Foreword
    7. Preface
      1. Android Studio versus Android Developer Tools (ADT)
      2. University Use
      3. Cordova as a Moving Target
      4. A Comment on Source Code
      5. The Book’s Web Site
    8. Acknowledgments
    9. About the Author
    10. 1. The What, How, Why, and More of Apache Cordova
      1. An Introduction to Apache Cordova
      2. What Is Adobe PhoneGap?
      3. A Little PhoneGap/Cordova History
      4. Cordova Components
      5. Access to Native APIs
      6. Cordova User Interface Capabilities
      7. Supported Platforms
      8. Cordova License
      9. Working with Cordova
        1. Designing for the Container
        2. Coding Cordova Applications
        3. Building Cordova Applications
      10. Putting Cordova to Best Use
      11. Getting Support
      12. Resources
      13. Cordova Going Forward
      14. Hybrid Application Frameworks
      15. Wrap-Up
    11. 2. Anatomy of a Cordova Application
      1. Hello World!
      2. Cordova Initialization
      3. Leveraging Cordova APIs
      4. Structuring Your Application’s Code
      5. The Generated Web Application Files
      6. Responsive Design and Cordova
      7. Wrap-Up
    12. 3. Configuring a Cordova Development Environment
      1. Installing the Cordova CLI
        1. Android Development Tools
        2. iOS Development Tools
        3. CLI Installation
      2. Installing Plugman
      3. Wrap-Up
    13. 4. Using the Cordova Command-Line Interfaces
      1. Troubleshooting
        1. Configuring Proxy Settings
        2. Enabling Verbose Output
      2. The Cordova CLI
        1. Cordova CLI Command Summary
        2. Using the Cordova CLI
        3. Upgrading Cordova and Cordova Projects
      3. The Plugman CLI
        1. Plugman CLI Command Summary
        2. Using the Plugman CLI
      4. Wrap-Up
    14. 5. The Mechanics of Cordova Development
      1. Cordova Development Issues
        1. Dealing with API Inconsistency
        2. Application Graphics, Splash Screens, and Icons
      2. Developing Cordova Applications
      3. Configuring a Cordova Application
      4. Testing Cordova Applications
      5. Leveraging Cordova Debugging Capabilities
        1. Using alert()
        2. Writing to the Console
      6. Debugging and Testing Using External Tools
        1. Weinre
        2. Ripple Emulator
        3. PhoneGap Developer App
        4. GapDebug
      7. Wrap-Up
    15. 6. Automation and the Cordova CLI
      1. Automating the Project Setup Step
        1. Windows Command File
        2. Bash Script
        3. Cross-Platform Approach Using NodeJS
      2. Automating the Cordova Process
      3. Wrap-Up
    16. 7. Android Development with Cordova
      1. Using the Android Developer Tools
        1. Managing the Android SDK
        2. Using the Android Virtual Device Manager
        3. Using the ADT IDE
      2. Monitoring Application Activity Outside of the ADT IDE
        1. Grabbing a Screen Shot
      3. Testing on a Physical Device
      4. Using the Chrome Debugging Tools
      5. Wrap-Up
    17. 8. Firefox OS Development with Cordova
      1. Firefox OS Developer Tools
      2. Debugging with the Firefox OS Simulator
      3. Debugging Applications on a Firefox OS Device
      4. Wrap-Up
    18. 9. iOS Development with Cordova
      1. Working with Xcode
      2. Testing Cordova Applications in Xcode
      3. Using the Safari Web Inspector
      4. Wrap-Up
    19. 10. Ubuntu Development with Cordova
      1. Installing the Cordova CLI on Ubuntu
      2. Debugging Ubuntu Applications
      3. Wrap-Up
    20. 11. Windows Development with Cordova
      1. Windows versus WP8 Projects and Cordova
      2. Windows Phone Limitations and Security Restrictions
        1. JavaScript alert Not Supported
        2. Application Security Model Limitations
      3. Windows Development System Requirements
      4. Windows Phone Development Tools
      5. Windows App Store Setup
      6. Configuring a Windows Phone Device for Application Testing
      7. Cordova Development Workflow Using Visual Studio
        1. Creating a Project
        2. Opening a Cordova Project
        3. Running a Cordova Application in Visual Studio
        4. Controlling the Windows Phone Emulator
        5. Debugging Cordova Applications Using Visual Studio
      8. Using Visual Studio Tools for Apache Cordova
      9. Wrap-Up
    21. 12. Using PhoneGap Build
      1. What Is PhoneGap Build?
        1. Quick Prototyping
        2. Collaboration
        3. Content Refresh through Hydration
      2. Using PhoneGap Build
        1. A Quick Example
        2. Configuring a PhoneGap Build Application
        3. Adding Plugins to a PhoneGap Build Project
        4. Deploying PhoneGap Build Applications
      3. Wrap-Up
    22. 13. Using the PhoneGap CLI
      1. Getting Help
      2. Project Management
      3. Anatomy of the Default PhoneGap Application
      4. PhoneGap CLI Workflow Differences
      5. Interacting with the PhoneGap Build Service
      6. Wrap-Up
    23. 14. Working with the Cordova APIs
      1. The Cordova Core APIs
      2. Working with the Cordova API Documentation
      3. Checking API Availability
      4. Catching Errors
      5. Setting Application Permissions
      6. Cordova Objects
        1. Connection Type
        2. device
      7. Alerting the User
        1. Hardware Notifications
        2. Visual Notifications
      8. Cordova Events
      9. Hardware APIs
        1. Accelerometer
        2. Compass
        3. Geolocation
        4. Camera
        5. Capturing Media Files
      10. Globalization
      11. Working with the Contacts Application
      12. Playing/Recording Media Files
      13. InAppBrowser
        1. Loading Content
        2. Browser Window Events
        3. Execute Scripts
        4. Insert CSS
      14. Splashscreen
      15. StatusBar
      16. Wrap-Up
    24. 15. Cordova Development End to End
      1. About the Application
      2. Creating the Application
      3. Using Merges
      4. Application Icons
      5. Testing the Application
      6. Wrap-Up
    25. 16. Creating Cordova Plugins
      1. Anatomy of a Cordova Plugin
      2. Creating a JavaScript-Only Plugin
        1. plugin.xml File
        2. The Plugin’s mol.js File
        3. Testing the Plugin
      3. Creating a Cordova Native Plugin
        1. Creating the Android Plugin
        2. Creating the iOS Plugin
      4. Publishing Plugins
      5. Wrap-Up
    26. 17. Using Third-Party UI Frameworks with Cordova
      1. Adobe Topcoat
      2. jQuery Mobile
      3. Bootstrap
      4. SAP OpenUI5
      5. Ionic Framework
      6. Onsen UI
      7. Wrap-Up
    27. 18. Using Third-Party Tools with Cordova
      1. Code Validation Tools
        1. JSLint
        2. JSHint
      2. Code Editors
        1. Adobe Brackets
        2. WebStorm
      3. Developer Productivity Enhancement Tools
        1. AppGyver
        2. Eclipse THyM
      4. Build Tools
        1. Gulp
        2. Grunt
      5. Wrap-Up
    28. Index
    29. Code Snippets