Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is ABRecordID a reliable way to identify unique contacts?

My app uploads contacts, and, in the future, will need to update them. Is using the ABRecordID a reliable way to identify people, or is it possible for a new record to obtain the ID of a deleted record?

To optimize uploads, I would like to upload only the records that have been modified or created since the last upload. I'm currently storing a copy of the person's contacts using core data. I'd like to slim down the footprint of my app and speed up the execution time of scanning through the person's address book looking for modified/new contacts and limit the amount that needs to be uploaded. After analyzing some people's address books, the number of contacts can range from 30 to around 30,000. Dealing with 30,000 contacts is a nightmare.

like image 896
JeffRegan Avatar asked Jun 04 '13 15:06

JeffRegan


1 Answers

A new record will not obtain an id previously associated with a deleted record. ABRecordIDs are unique in that regard. But they are not necessarily consistent over time, a couple of things can cause the id to change. The user turning on or off iCloud may cause the id to change, as may restoring the device from itunes. That said, ABRecordID is still your best bet for getting a unique id for a contact. You just need to double check that things line up when using it. Apple suggests the following in the address book programming guide:

The recommended way to keep a long-term reference to a particular record is to store the first and last name, or a hash of the first and last name, in addition to the identifier. When you look up a record by ID, compare the record’s name to your stored name. If they don’t match, use the stored name to find the record, and store the new ID for the record.

like image 96
Ben Swanson Avatar answered Oct 16 '22 09:10

Ben Swanson