QuickBlox Documentation

QuickBlox provides powerful Chat API and SDK to add real-time messaging and video calls to your web and mobile apps. Learn how to integrate QuickBlox across multiple platforms.

Address Book

Learn how to store and sync the phone contact list with QuickBlox.

Address Book API provides an interface to work with the phone address book. Upload it to the server and retrieve already registered QuickBlox users from your address book.

Visit our Key Concepts page to get an overall understanding of the most important QuickBlox concepts.

Before you begin

  1. Register a QuickBlox account. This is a matter of a few minutes and you will be able to use this account to build your apps.
  2. Configure QuickBlox SDK for your app. Check out our Setup page for more details.
  3. Create a user session to be able to use QuickBlox functionality. See our Authentication page to learn how to do it.

Upload address book

First of all, you need to upload your address book to the backend. It's a normal practice to do a full upload for the 1st time and then upload new contacts on future app logins.

let contact = {};
contact.name = "Apple service";
contact.phone = "1-800-275-2273";
let contactsArray = [contact];
let options = {
  force: 1,
};

function addressBookSaved(error, result) {
  if (error) {
    console.log(error);
  } else {
    // process response
  }
}

QB.addressbook.uploadAddressBook(contactsArray, options, addressBookSaved);
  • You also can edit an existing contact by providing a new name for it.
  • You also can upload more contacts, not just all in one request. They will be added to your address book on the backend. If you want to override the whole address book on the backend just provide force: 1 option.
  • A device UDID is a unique device identifier. The UDID is used in cases where a user has two or more devices and contacts sync is off. Otherwise, a user has a single global address book. The UDID maximum length is 64 symbols.

Retrieve address book

You can retrieve your uploaded address book using the code snippet below.

function addressBookSaved(error, result) {
  if (error) {
    console.log(error);
  } else {
    // process response
  }
}

QB.addressbook.get(addressBookSaved);
//with UDID
QB.addressbook.get(UDID, addressBookSaved);

Update contacts

If you need to update the name or phone number in your address book contacts, you should use the code sample below.

let contact = {};
contact.name = "Apple service";
contact.phone = "1-800-275-2273";
let contactsArray = [contact];

function prepareForUpdate(contacts) {
  return contacts.map(function (contact, index) {
    contact.name += " Updated";
    return contact;
  });
}

var contactsUpdated = prepareForUpdate(contactsArray);

function addressBookUpdated(error, result) {
  if (error) {
    console.log(error);
  } else {
    // process response
  }
}

QB.addressbook.uploadAddressBook(contactsUpdated, addressBookUpdated);

Delete contacts

You can delete contacts by using the code snippet below.

let contact = {};
contact.name = "Apple service";
contact.phone = "1-800-275-2273";
let contactsArray = [contact];

function prepareForDestroy(contacts) {
  return contacts.map(function (contact, index) {
    if (index % 2 !== 0) {
      delete contact.name;
    }
    contact.destroy = 1;
    return contact;
  });
}

var contactsDestroy = prepareForDestroy(contactsArray);

function removedContacts(error, result) {
  if (error) {
    console.log(error);
  } else {
    // process response
  }
}

QB.addressbook.uploadAddressBook(contactsDestroy, removedContacts);
//with UDID
var options = {
  udid: UDID,
};
QB.addressbook.uploadAddressBook(contactsDestroy, options, removedContacts);

Retrieve registered users

Using this request, you can easily retrieve the QuickBlox users - your address book contacts that are already registered in your app, so you can start communicating with these users right away.

function addressBookGot(error, result) {
  if (error) {
    console.log(error);
  } else {
    // process response
  }
}

QB.addressbook.getRegisteredUsers(addressBookGot);

Push notification on new contact joined

There is a way to get a push notification when some contact from your Address Book has been registered in the app. You can enable this feature at QuickBlox Dashboard. Just follow Dashboard => YOUR_APP => Users => Settings direction and enable push notifications for new contacts.

enable push notification for a new contact, for web app

Updated 4 months ago


Address Book


Learn how to store and sync the phone contact list with QuickBlox.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.