Cordova provides access to the contacts on the user's device through the org.apache.cordova.contacts
plugin.
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.
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:
Add the following HTML to
index.html
:<div data-role="view" id="app-contact" data-title="Contacts" data-layout="layout"> <h3>Contacts</h3> <p> <a data-role="button" data-click="app.demos.contacts.onAddContact"> Add Contact</a> <a data-role="button" data-click="app.demos.contacts.onFetchContacts"...