Dealing with duplicate contacts due to linked cards in iOS' Address Book API

前端 未结 5 1998
挽巷
挽巷 2020-12-12 14:19

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 a

5条回答
  •  执念已碎
    2020-12-12 15:18

    I've been using ABPersonCopyArrayOfAllLinkedPeople() in my app for some time now. Unfortunately, I've just discovered that it doesn't always do the right thing. For example, if you have two contacts that have the same name but one has the "isPerson" flag set and the other does not, the above function won't consider them "linked". Why is this an issue? Because Gmail(exchange) sources don't support this boolean flag. If you try to save it as false, it will fail, and the contact you saved in it will come back on the next run of your app as unlinked from the contact you saved in iCload (CardDAV).

    Similar situation with social services: Gmail doesn't support them and the function above will see two contacts with the same names as different if one has a facebook account and one does not.

    I'm switching over to my own name-and-source-recordID-only algorithm for determining whether two contact records should be displayed as a single contact. More work but there's a silver lining: ABPersonCopyArrayOfAllLinkedPeople() is butt-slow.

提交回复
热议问题