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

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

问题描述

一个少数主题/13089845#13089845" rel="noreferrer">Apple 的论坛 供最终用户使用,但除了许多指向 404 支持页面,我实际上无法修复所有应用程序用户的通讯录.我更愿意优雅地处理它而不打扰用户.更糟糕的是,似乎我不是唯一一个遇到这个问题的人,因为 WhatsApp 显示包含重复联系人的相同列表.

只是为了清楚重复联系人的来源,我不会存储、缓存或以其他方式尝试对数组 ABAddressBookCopyArrayOfAllPeople 返回的智能.所以重复记录直接来自 API 调用.

有谁知道如何处理或检测这些关联的卡片,以防止出现重复记录?Apple 的通讯录应用可以做到这一点,我们其他人怎么能做到呢?

更新:我编写了一个库并将其放在 Cocoapods 上以解决手头的问题.请参阅下面的答案

解决方案

@Daniel Amitay 提供的方法包含了非常有价值的掘金,但不幸的是代码还没有准备好使用.对联系人进行良好的搜索对我和许多应用程序至关重要,因此我花了很多时间来解决这个问题,同时还解决了与 iOS 5 和 6 兼容的地址簿访问问题(通过块处理用户访问).它解决了由于不正确同步源导致的许多链接卡片以及来自新添加的 Facebook 集成的卡片.

我编写的库使用内存(可选磁盘)Core Data 存储来缓存地址簿记录 ID,提供简单的后台线程搜索算法,返回统一的地址簿卡片.

源代码可在 我的 github 存储库上找到,这是一个 CocoaPods 豆荚:

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天全站免登陆