在iOS的通讯录API中处理由于链接的卡片重复的联系人 [英] Dealing with duplicate contacts due to linked cards in iOS' Address Book API

查看:243
本文介绍了在iOS的通讯录API中处理由于链接的卡片重复的联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几个主题 https://discussions.apple.com/message/13089845#13089845rel =noreferrer>苹果论坛为最终用户,但除了许多指向 404支持页面,我无法真正地修复我所有的应用程序的用户地址簿。我宁愿喜欢处理优雅而不用打扰用户。更糟糕的是,似乎我不是唯一一个这个问题,因为 WhatsApp显示包含重复联系人的相同列表



只是为了清楚起点重复的联系人,我不存储,缓存或以其他方式试图聪明地关于数组 ABAddressBookCopyArrayOfAllPeople 返回。所以重复的记录直接来自API调用。



有谁知道如何处理或检测这些链接的卡,防止重复的记录显示?苹果的联系人应用程序做到这一点,我们其他人如何也可以这样做?



更新:我写了一个图书馆,把它放在Cocoapods上解决问题手。请参阅我的答案

解决方案

@Daniel Amitay提供的方法包含了非常有价值的块,但遗憾的是代码没有准备好使用。对联系人进行良好的搜索对于我和许多应用程序至关重要,所以我花了相当多的时间来获得正确的权限,同时也解决了iOS 5和6兼容的通讯录访问问题(通过块处理用户访问)。它解决了许多链接的卡,由于不正确的同步源和新增的Facebook集成的卡。



我写的库使用内存(可选地,磁盘)核心数据存储缓存地址簿记录ID,提供简单的后台线程搜索算法,返回统一的地址簿卡。



源代码可以在<一个href =https://github.com/epologee/EEEUnifiedAddressBook =nofollow>我的github仓库,这是一个 CocoaPods pod:

  pod'EEEUnifiedAddressBook'


Some beta-users of my upcoming app are reporting that the list of contacts contain a lot of duplicate records. I'm using the result from ABAddressBookCopyArrayOfAllPeople as the data source for my customized table view of contacts, and it baffles me that the results are different from the iPhone's 'Contacts' app.

When looking more closely at the Contacts app, it seems that the duplicates originate from entries with "Linked Cards". The screenshots below have been obfuscated a bit, but as you see in my app on the far right, "Celine" shows up twice, while in the Contacts app on the left there's only one "Celine". If you click the row of that single contact, you get a "Unified Info" card with two "Linked Cards" (as shown in the center, I didn't use Celine's contact details because they didn't fit on one screenshot):

The issues around "Linked Cards" have quite a few topics on Apple's forums for end users, but apart from the fact that many point to a 404 support page, I can't realistically go around fixing all of my app's users' address books. I would much rather like to deal with it elegantly and without bothering the user. To make matters worse, it seems I'm not the only one with this issue, since WhatsApp is showing the same list containing duplicate contacts.

Just to be clear about the origins of the duplicate contacts, I'm not storing, caching or otherwise trying to be smart about the array ABAddressBookCopyArrayOfAllPeople returns. So the duplicate records come directly from the API call.

Does anyone know how to deal with or detect these linked cards, preventing duplicate records from showing up? Apple's Contacts app does it, how can the rest of us do so too?

UPDATE: I wrote a library and put it on Cocoapods to solve the issue at hand. See my answer below

解决方案

The approach that @Daniel Amitay provided contained nuggets of great value, but unfortunately the code is not ready for use. Having a good search on the contacts is crucial to my and many apps, so I spent quite a bit of time getting this right, while on the side also addressing the issue of iOS 5 and 6 compatible address book access (handling user access via blocks). It solves both the many linked cards due to incorrectly synched sources and the cards from the newly added Facebook integration.

The library I wrote uses an in-memory (optionally on-disk) Core Data store to cache the address book record ID's, providing an easy background-threaded search algorithm that returns unified address book cards.

The source is available on a github repository of mine, which is a CocoaPods pod:

pod 'EEEUnifiedAddressBook'

这篇关于在iOS的通讯录API中处理由于链接的卡片重复的联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆