What is the way to get all contacts using PhoneGap?

phonegap contacts api tutorials

phonegap contacts api tutorials

What is the way to get all contacts using PhoneGap?

You can easily find the contact list with the information like phone number, contact name, email address and birthday from Android devices by simply using PhoneGap.

Following steps explain how to use Phonegap to get the contact information.


Step 1 :

Create Project using 

cordova create AllContacts com.suranka.allcontacts AllContacts

Step 2 :

change your working Directory 

cd AllContacts

Step 3:

Add your platform 

cordova platform add android

Step 4

Add Contact Plugin

cordova plugin add org.apache.cordova.contacts



Step 5:

Goto your html page (www/index.html) and write this code

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var options = new ContactFindOptions();
var fields = ["*"];
navigator.contacts.find(fields, onSuccess, onError, options);
//on success handler
function onSuccess(contacts)
for (var i = 0; i < contacts.length; i++)
//error handler
function onError()
 alert("Some Error Occured");

Share This

Share this post with your friends!