I need to select the address book source in which contacts are created by my app.
In the Contacts app, when I select "< Groups", I get the options
Using the function ABAddressBookCopyArrayOfAllSources
I get source records for
The names are in no way descriptive and I would like to show the account names in addition to the source name or type, just like the Contact app does.
Do you know a way to find out the account name of a source, or to retrieve all existing account names and the sources of each account? Any other ideas to get more descriptive entries?
It's in your contact record in the Contacts app. For any of your contacts you can Edit to change addresses, add additional address locations as well as all other type of contact information.
Go to Settings > Contacts > Accounts. Tap the account that has contacts that you want to add or remove. To add contacts, turn on Contacts. To remove contacts, turn off Contacts, then tap Delete from My iPhone.
In the Applications Support Folder there is a Folder called AddressBook. In this folder is a folder called Metadata. In here are files, one for each contact.
As of iOS 5.1 there is no public API for this.
One would hope that ABRecordCopyCompositeName()
would get what you're after — it provides the "human friendly" name for Person and Group records — but alas it returns null.
As Graham pointed out (when offering a bounty) directly asking for kABSourceNameProperty
provides the wrong answer.
ABAddressBookRef addressBook = ABAddressBookCreate();
CFArrayRef sources = ABAddressBookCopyArrayOfAllSources(addressBook);
CFIndex i, c = CFArrayGetCount(sources);
ABRecordRef curSource;
// Log each source name.
for (i=0; i<c; i++) {
curSource = CFArrayGetValueAtIndex(sources, i);
NSString *name = (__bridge_transfer NSString *)ABRecordCopyCompositeName(curSource);
NSLog(@"Alas this is null: %@", name);
NSString *directValue = (__bridge_transfer NSString *)ABRecordCopyValue(curSource,kABSourceNameProperty);
NSLog(@"And direct access gives wrong answer: %@", directValue);
}
CFRelease(sources);
CFRelease(addressBook);
All I can suggest is filing a Radar to ask that ABRecordCopyCompositeName()
be made to make whatever service Contacts itself is using available to the rest of us.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With