3
votes

Long-time lurker, first-time poster. Please forgive me if I make n00b mistakes.

The problem I am having is programmatically distinguishing between CardDAV sources.

I am trying to find a specific CardDAV source on the iphone, which corresponds to the account on our cardDAV server. The only property I can see that should help is ABSource.kABSourceNameProperty, but this is just some meaningless string for every CardDAV source like "Contacts" or "Address Book", no matter what settings the user uses on their phone. That means the app has no way to determine if a specific Contact source is GMail cardDAV, iCloud cardDAV, our CardDAV, and so on.

For example, here are the source types and names for a device that has iCloud, Exchange, Gmail, and Facebook contact sources:

ABManager: 1 of 7 sources: cardDAV - 
ABManager: 2 of 7 sources: exchangeGAL - (null)
ABManager: 3 of 7 sources: cardDAV - Card
ABManager: 4 of 7 sources: exchange - Contacts
ABManager: 5 of 7 sources: exchange - Lync Contacts
ABManager: 6 of 7 sources: exchange - Suggested Contacts
ABManager: 7 of 7 sources: cardDAV - Address Book

There is no way to tell which of the 3 CardDAV sources is Gmail versus iCloud etc.

How can I compare different CardDAV contact sources on iOS, and determine which one belongs to our CardDAV server?

Background, in case it helps: I am developing an iOS app that helps a user copy contacts from their existing contact sources to a cardDAV contact source on our server. In other words: the user sets up a new CardDAV account (the source is installed on the iPhone via .mobileprovision profile), and now they run this app to copy contacts to the new CardDav account.

Thanks for your help!

1
Did you find any solution to this problem?freshking
No. My workaround was to create a contact on the server first, then establish the connection via iOS APIs (CardDAV), and figure out which source had that created contact.xaphod
Thats actually how I am doing it at the moment. The Problem here is that the app can't know if the user ever disabled or deleted that account from the device.freshking

1 Answers

0
votes

In case contacts come from address books provided by a CardDAV server you probably now the address book that this contact comes from. And as soon a you know the address book you probably can determine the source/server.

However I think your problem is more a synchronization issue. If every vCard in your system has a unique identifier (UID) and revision number (REV) as well as knowing each property cardinality you can build some sort of automatic synchronization mechanism.

UID property:

REV property (date/time in ISO 8601 format):

You may also need a manual conflicts resolution mechanism.

A more sophisticated synchronization mechanism was introduced in vCard 4.0 with PID property. However vCard 4.0 is not widely spread yet.