O'Reilly logo

CoffeeScript Application Development Cookbook by Mike Hatfield

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

Using contacts

Cordova provides access to the contacts on the user's device through the org.apache.cordova.contacts plugin.

Getting ready

Install the contacts plugin using the following command:

cordova plugin add org.apache.cordova.contacts

Once installed, a contacts object will be added to the navigator, which provides the contacts.create() and contacts.find() methods.

How to do it...

To create a contact, we use the navigator.contacts.create() method. It returns a contact object that can be used by your application. You can pass an object literal to this create() method, which will initialize the various contact properties:

  1. Add the following HTML to index.html:
    <div data-role="view" id="app-contact" data-title="Contacts" data-layout="layout"> <h3>Contacts</h3> ...

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

Start Free Trial

No credit card required