Is there a way to get Address Book contact ID's from Sync Services contact ID's?
Asked Answered
D

1

13

When getting the modified contacts from Sync Services, through the applyChange:forEntityName:remappedRecordIdentifier:formattedRecord:error method. The IDs in the address book are of the form 2C13E20E-6B24-4090-81FA-7A1E8B28119B, and even though some IDs of this kind are present in the ISyncChange * object, those are not actual contact ID's that can be found in the address book...

Is there a way to find out from Sync Services what a certain contact's ID is in the Address Book?


The reason for asking is that when saving large pictures for contacts in the Address Book, Sync Services does not save those pictures in their internal data storage. Therefore, contacts that have been modified or added with a large picture will be returned by Sync Services without the picture, basically offering incomplete information.

I need to get the Address Book ID, so that I can look up the contact's picture in ~/Library/Application Support/Address Book/Images/

Thanks!

Dichroite answered 2/11, 2011 at 11:13 Comment(0)
A
1

It's a bad idea to rely on the Address Book id relating to an image in ~/Library/Application Support/Address Book/Images/ - you'd be better off finding an API that provides you the data you want to work with, because you aren't guaranteed that the image will be there then, or later (after an upgrade, this could all change!).

After a small amount of research, it appears that the api you want is documented here : http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AddressBook/Tasks/AccessingData.html#//apple_ref/doc/uid/20001023-103617

It's a little unwieldy because you necessarily need to understand their ABImageClient protocol and provide a callback, but I don't think it's that bad. This approach is much better than what you were doing - it's the Apple sanctioned way of getting this data and you won't have to worry about it breaking in the future.

Amagasaki answered 4/1, 2012 at 22:54 Comment(2)
I suppose you mean using imageData in order to get the image data for a contact. How do I get that contact? I need to have his ID somehow.Dichroite
Hmm, I completely missed that part of the question when I read this originally. I'm trying to read up on the sync services documentation for ApplyChange: ForEntityName: but since Apple decided to deprecate that API in Lion, they removed all of the documentation from developer.apple.com. Maybe someone more knowledgable about sync services will know how to get from the iSyncChange object ID to the underlying uuid for the contact in AB.Amagasaki

© 2022 - 2024 — McMap. All rights reserved.