Identify ABRecord records uniquely: Is [ABRecord uniqueId] immutable?
Asked Answered
N

2

5

I need to reference ABPerson records from within an application. I use the unique ID provided by

  - (NSString *)uniqueId

and attach it to my in-app contact record.

Additionally, I save ABPerson's vCardRepresentation as a fallback. In case the app isn't any longer able to locate the ABRecord using the uniqueID, the app asks the user to recover the adressbook record using the saved vCardRepresentation. All works fine.

Unfortunately, a friend told me, that uniqueId isn't immutable: During a sync, uniqueId may suddenly change.

According to him, somewhere in iOS documentation, Apple explains that no way exists to immutable identify ABPersons using uniqueId. In OS X' Cocoa documentation, I failed to find such a hint.

On a given Mac, may the uniqueId change suddenly? If that's true, what's the correct way to identify ABPerson records from within an external application?

In case the uniqueID isn't immutable, I certainly may assign a custom property with a GUID. Unfortunately, custom fields do not sync.

Certainly, I'd prefer to use uniqueId.

Nader answered 16/8, 2011 at 20:46 Comment(1)
Sure thing. It's an interesting question.Ornate
O
5

For whats its worth, from Apple's techdoc:

kABUIDProperty The unique ID for this record. It’s guaranteed never to change, no matter how much the record changes. If you need to store a reference to a record, use this value. Type: kABStringProperty. Available in Mac OS X v10.2 and later. Declared in ABGlobals.h.

Okay answered 23/9, 2011 at 8:21 Comment(1)
Thx! Certainly, I'm aware of this detail. Even someone from ADC told the other developer to NOT trust uniqueIDs. Anyway...Nader
C
2

It looks like the kABUIDProperty approach might not work anymore. I came across this blog entry with more discussion in the comments at:
http://blog.clickablebliss.com/2011/11/07/addressbook-record-identifiers-on-mac-and-ios/.

A case in point: If a user decides to turn on iCloud sync, the unique ids in that user's address book will change. If the users turns off iCloud sync, they'll change again.

Addendum: it might be worthwhile looking at the StackOverflow entry here.

Apple's docs do say this (quoted from the link):

"The recommended way to keep a long-term reference to a particular record is to store the first and last name, or a hash of the first and last name, in addition to the identifier. When you look up a record by ID, compare the record’s name to your stored name. If they don’t match, use the stored name to find the record, and store the new ID for the record."

Chancellor answered 6/8, 2013 at 15:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.