Some beta-users of my upcoming app are reporting that the list of contacts contain a whole lot of duplicate records. I am employing the outcome from ABAddressBookCopyArrayOfAllPeople as the data source for my customized table view of contacts, and it baffles me that the results are unique in the iPhone's 'Contacts' app.
When hunting more closely in the Contacts app, it appears that the duplicates originate from entries with "Linked Cards". The screenshots below have been obfuscated a little, but as you see in my app around the far right, "Celine" shows up twice, whilst in the Contacts app on the left there's only one Celine Handbags "Celine". In the event you click the row of that single get in touch with, you get a "Unified Info" card with two "Linked Cards" (as shown within the center, I did not use Celine's speak to details simply because they did not match on 1 screenshot):
The difficulties about "Linked Cards" have fairly a number of topics on Apple's forums for end customers, but apart from the fact that several point to a 404 support web page, I can not realistically go about fixing all of my app's users' address books. I would a lot rather prefer to deal with it elegantly and without the need of bothering the user. To make matters worse, it appears I'm not the only 1 with this concern, because WhatsApp is displaying the same list containing duplicate contacts.
Simply to be clear regarding the origins with the duplicate contacts, I'm not storing, caching or otherwise trying to be intelligent in regards to the array ABAddressBookCopyArrayOfAllPeople returns. So the duplicate records come straight in the API contact.
Does everyone understand how to take care of or detect these linked cards, stopping duplicate records from showing up? Apple's Contacts app does it, how can the rest of us do so too?
But that's lame, appropriate? It targets the on-device address book, but not additional contacts that may be in Exchange or other fancy syncing address books.
You now have an NSSet containing NSSets of linked ABRecord objects. Possessing a fantastic search on the contacts is important to my and lots of apps, so I spent rather a bit of time finding this suitable, whilst on the side also addressing the problem of iOS 5 and 6 compatible address book access (handling user access via blocks). It solves both the many linked cards resulting from incorrectly synched sources plus the cards from the newly added Facebook integration.
The library I wrote utilizes an in-memory (optionally on-disk) Core Information retailer to cache the address book record ID's, supplying an easy background-threaded search algorithm that returns unified address book cards.
The supply is obtainable around the Twelve Twenty Toolkit Celine Bags Outlet github repository, but a lot more effortlessly added to your project via cocoapods:
I've been employing ABPersonCopyArrayOfAllLinkedPeople() in my app for some time now. Regrettably, I've just discovered that it does not generally do the proper issue. By way of example, when you have two contacts which have the identical name but 1 has the "isPerson" flag set and the other will not, the above function will not contemplate them "linked". Why is this an issue? Since Gmail(exchange) sources don't help this boolean flag. Should you attempt to save it as false, it can fail, and the speak to you saved in it will come back around the next run of your app as unlinked in the get in touch with you saved in iCload (CardDAV).
Equivalent predicament with social services: Gmail does not assistance them and also the function above will see two contacts with the exact same names as distinctive if one has a facebook account and one doesn't.