Home > Store

Apache Cordova API Cookbook, Rough Cuts

Rough Cuts

  • Available to Safari Subscribers
  • About Rough Cuts
  • Rough Cuts are manuscripts that are developed but not yet published, available through Safari. Rough Cuts provide you access to the very latest information on a given topic and offer you the opportunity to interact with the author to influence the final publication.

Not for Sale

Description

  • Copyright 2015
  • Dimensions: 7 X 9
  • Pages: 320
  • Edition: 1st
  • Rough Cuts
  • ISBN-10: 0-13-383854-4
  • ISBN-13: 978-0-13-383854-1

This is the Rough Cut version of the printed book.

Using Apache Cordova, mobile developers can write cross-platform mobile apps using standard HTML5, JavaScript, and CSS, and then deploy those apps to every leading mobile platform with little or no re-coding. Apache Cordova API Cookbook provides experienced mobile developers with details about how each Cordova API works and how to use the APIs in their own applications. Coverage is included for all Cordova/PhoneGap 3 APIs.

Instead of just showing short snippets of code to explain a particular API, this guide is chock full of complete examples. You’ll find more than thirty complete Cordova applications that work on Android, iOS, Windows, and more. The sample applications demonstrate exactly what each API does and how it works, while the chapter content describes the limitations on the leading target platforms (and even offers possible workarounds).

Through realistic “cookbook” example code, mobile developer John Wargo helps you master the Cordova APIs and understand how to use them in your Cordova applications.

Topics include

  • Accelerometers, compass, and geolocation
  • Image, video, and audio–capture, playback, and management
  • Determining connection and device information
  • Interacting with the Contacts application
  • Responding to application events
  • Accessing the device file system
  • Globalizing apps
  • Using the InAppBrowser
  • Notifications
  • Custom splash screens 

Special care has been taken to make the code easily readable and digestible by the reader. This guide provides the most accessible coverage, anywhere, of Apache Cordova APIs.

Sample Content

Table of Contents

Foreword xiii

Preface xv

Acknowledgments xvii

About the Author xix

Chapter 1: Introduction to Apache Cordova 1

Introduction to Apache Cordova 1

Supported Platforms 5

Coding Cordova Applications 5

Configuring a Cordova Development Environment 6

Building Cordova Applications 6

Anatomy of a Cordova Application 9

Resources 15

Wrap Up 17

Chapter 2: Accelerometer 19

Measuring Device Orientation 20

Watching a Device’s Orientation 28

What Can Go Wrong 33

Chapter 3: Camera 35

Taking a Picture 36

Configuring Camera Options 44

iOS-Only Capabilities 58

What Can Go Wrong 58

Chapter 4: Capture 61

Using the Capture API 62

Configuring Capture Options 66

Capture in Action 66

What Can Go Wrong 77

Chapter 5: Compass 79

Getting the Device Heading 79

Watching the Device Heading 86

What Can Go Wrong 95

Chapter 6: Connection 97

Using the Connection API 97

An Example 99

What Can Go Wrong 103

Chapter 7: Contacts 105

Creating a Contact 106

Searching for Contacts 115

Cloning Contacts 124

Removing Contacts 124

What Can Go Wrong 124

Chapter 8: Device 127

Using the Device API 127

An Example 128

What Can Go Wrong 133

Chapter 9: Events 135

Managing Event Listeners 136

deviceready Event 137

Application Status Events 138

Battery Status Events 141

Button Events 144

Network Status Events 149

What Can Go Wrong 152

Chapter 10: File 153

Storage Locations 154

Accessing the Device’s File System 156

Reading Directory Entries 159

Accessing FileEntry and DirectoryEntry

Properties 163

Writing Files 167

Reading Files 170

Deleting Files or Directories 172

Copying Files or Directories 173

Moving Files or Directories 173

Transferring Files 174

What Can Go Wrong 179

Chapter 11: Geolocation 181

Updates

Submit Errata

More Information