I am creating an application to sync the addressbook. I have synced the addressbook records into the local core data based database and I could already fetch them. Syncing a record is easy using the ABRecordId. I store the record id for certain addressbook record into my local database, and so I can fetch a certain record based on the id. I can also implement the callback by implementing the ABAddressBookRegisterExternalChangeCallback. But is there a way to track change of a particular email. A user could change his email, how is it possible to know if a certain email has changed.

有帮助吗?

解决方案

There is no way to attach a "listener" that will somehow call a function in your app every time someone edits a contact. But, there is a way to keep your app up-to-date:

Store a variable in NSUserDefaults that contains the date of the last time you imported new contacts from the phone.

When your app resumes from the background or opens for the first time, you should query the phone's contacts for all of the records that have been modified since the date of the last time you synced with the contacts. This way, you can only process the updated contacts without iterating over every saved contact every time.

You should be able to sort the person records by this property: kABPersonModificationDateProperty (reference)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top