How whatsapp get updated contacts from addressbook

2020-07-05 06:49发布

问题:

My findings

I am designing a logic to sync contact with my Backend. I gone through some apps that doing same thing in IOS. I will take the example of WhatsApp, I found that When I update any contact in Native Addressbook, it reflect that change into Whatsapp withing a fraction.

My Concern

I just want to know that how it is syncing in a very faster way. Even a new contact gets synced with its Remote server and get displayed on contact, and with the ability to initiate Whatsapp chat if that number is registered one.

Summary of Queries

So, in nutshell my queries are,

  1. How Whatsapp is syncing the contact?
  2. How whatsapp is getting just updated contact list from Native Addressbook (if it's doing so) ?
  3. How whatsapp is just getting just new Contact added in addressbook, is there anything that manages like timestamp or anything else?

I know the following things are there like,

ABAddressBookGetPersonCount
ABAddressBookGetPersonWithRecordID
ABAddressBookCopyArrayOfAllPeople

Using the ABAddressBookGetPersonCount i can know if any new contacts are there but still how i will be able to know its Record ID without iterating each contact using ABAddressBookCopyArrayOfAllPeople

So i am just asking for the way to get just updated list.

回答1:

The way to do this is by registering an external change callback. This way, your app will be notified of any changes to the address book as soon as they happen.