How to access address book / contacts on iOS?

Hi there.

I have installed the cordova contacts plugin and have tried all I can find to access the contacts on the iOS address book but nothing I do works.

I would expect a prompt to appear saying ‘this app would like to access your address book’ etc at the very least, but I can’t even get that to show up.

Can anyone point me in a direction of some clearer example code / guide?

Basically I have created the ionic tabs app. I am now trying to make a view that lists out the users contacts. Right now I can’t even get a contact to appear in an ‘alert’ window or anything. Spent 2 days on this so figured I would ask in case anyone can help :smile:

call get_contacts() on deviceready event.

function get_contacts() {
    var obj = new ContactFindOptions();
    obj.filter = "";
    obj.multiple = true;
    navigator.contacts.find(["displayName", "name", "phoneNumbers"], contacts_success, contacts_fail, obj);
function contacts_success(contacts) {
    debugError("contacts_success(): " +JSON.stringify( contacts));
function contacts_fail(msg) {
    debugError("get_contacts() Error: " + msg);

Thank you. unfortunately it appears that ionic uses a ‘platform ready’ method instead of device ready. I tried putting this into that area instead and nothing happens at all.

As noted, I used the ionic tabs basic app and am trying to work it in to the app.js (where the platform ready flag is) but nothing happens at all.

I’m sure I am missing something simple or obvious but at present still can’t get this to work.

ignore platform.ready event, create a device ready yourself and then try.

Thanks. Got it working.

Question is, how do I now put that into a function. The moment I move it into a function it doesn’t work anymore.

use a global variable and assign contacts in device ready, use that var in your function. i.e.

$scope.contacts = globalContacts;

how are you guys testing the contact book? obviously you can’t do it in the browser but even on the IOS emulator I can’t seem to get any console.log statements… are there any better tools?

console.log(…) statements output can be seen on xcode log window. You should directly run on real device from xcode and see log window of xcode.

@fox how and where did you placed device ready function? Would be great if you can share snippet.


I wrote a tutorial on how to use ngCordova Contacts plugin to create, find, and delete contacts. You will also find a working example.

##Click here to open a tutorial including working examples

You can use these functions:

$ionicPlatform.ready(function() {	

    $scope.contacts = {};  // We will use it to load contacts 	
	$ = {     // We will use it to save a contact

		"displayName": "Gajotres",
		"name": {
			"givenName"  : "Dragan",
			"familyName" : "Gaic",
			"formatted"  : "Dragan Gaic"
		"nickname": 'Gajotres',
		"phoneNumbers": [
				"value": "+385959052082",
				"type": "mobile"
				"value": "+385914600731",
				"type": "phone"
		"emails": [
				"value": "",
				"type": "home"
		"addresses": [
				"type": "home",
				"formatted": "Some Address",
				"streetAddress": "Some Address",
		"ims": null,
		"organizations": [
				"type": "Company",
				"name": "Generali",
				"department": "IT",
				"title":"Senior Java Developer"
		"birthday": Date("08/01/1980"),
		"note": "",
		"photos": [
				"value": ""
		"categories": null,
		"urls": null
    $scope.addContact = function() {
        $$ {
            console.log('Contact Saved!');
        }, function(err) {
            console.log('An error has occured while saving contact data!');

    // This function can take some time  so be patient
    $scope.getAllContacts = function() {
        $cordovaContacts.find({filter : 'Robert', fields:  [ 'displayName']}).then(function(allContacts) { //omitting parameter to .find() causes all contacts to be returned
            $scope.contacts = allContacts;

    $scope.removeContact = function() {
		$scope.removeContact = {};   // We will use it to save a contact
		$scope.removeContact.displayName = 'Gajotres'; // Contact Display Name			
        $cordovaContacts.remove($scope.removeContact).then(function(result) {
			console.log('Contact Deleted!');
        }, function(error) {
            console.log('An error has occured while deleting contact data!');


Also don’t forget to wrap everything into Ionic ready event.

More complex version can be found in a provided tutorial. Leave me a message if you have more question or if you think something is missing.

1 Like

Thanks gajotres !
if i wish to add more than one filter in getAllContacts() is it possible ?

Hello ionicer,
I made a demo app from example
When I tried to write to native contact
My code:
${“displayName”: “Steve Jobs”}).then(function(result) {
console.log(“Save successfully”);
}, function(error) {

this error message was displayed when I debugged on Simulator iOS + Safari.
Error: DataCloneError: DOM Exception 25
postMessage@[native code]
dispatchEvent@[native code]
Could you please advice this?
Many thanks.

I don’t see any follow to this question. I’m getting the exact same error trying to save. what does DataCloneError: DOM Exception 25 mean? Did this ever get resolved?