3

I am developing a app in which I have to add custom contacts to iPhone Contact list.

To elaborate that every contact in iPhone have a definite set of fields which we can be used to save contact info.

I want to know if we can

add custom fields apart from that ofexisting options in iPhone.

If its possible please show me the way to do that, googled it but didn't found any thing meaningfull.

Thanks in advance.

Toby Allen
  • 10,997
  • 11
  • 73
  • 124
Ankit Sachan
  • 7,690
  • 16
  • 63
  • 98

3 Answers3

3

From this.

ABRecordRef aRecord = ABPersonCreate(); 
    CFErrorRef  anError = NULL; 
    ABRecordSetValue(aRecord, kABPersonFirstNameProperty, 
                     CFSTR("Jijo"), &anError); 
    ABRecordSetValue(aRecord, kABPersonLastNameProperty, 
                     CFSTR("Pulikkottil"), &anError); 
    if (anError != NULL) { 

        NSLog(@"error while creating..");
    } 
    CFStringRef firstName, lastName; 
    firstName = ABRecordCopyValue(aRecord, kABPersonFirstNameProperty); 
    lastName  = ABRecordCopyValue(aRecord, kABPersonLastNameProperty); 




    ABAddressBookRef addressBook; 
    CFErrorRef error = NULL; 
    addressBook = ABAddressBookCreate(); 

    BOOL isAdded = ABAddressBookAddRecord (
                            addressBook,
                            aRecord,
                             &error
    );

    if(isAdded){

        NSLog(@"added..");
    }
    if (error != NULL) {
        NSLog(@"ABAddressBookAddRecord %@", error);
    } 
    error = NULL;

    BOOL isSaved = ABAddressBookSave (
                       addressBook,
                       &error
    );

    if(isSaved){

        NSLog(@"saved..");
    }

    if (error != NULL) {
        NSLog(@"ABAddressBookSave %@", error);
    } 

    CFRelease(aRecord); 
    CFRelease(firstName); 
    CFRelease(lastName); 
    CFRelease(addressBook);

If you need to store data in there, I think your only option is kABPersonNoteProperty, but I'm no expert on this.

Edit: link.

Answer: nope!

Edit: you can also prompt the user to add an address book entry as done here.

Community
  • 1
  • 1
Kenny Winker
  • 11,919
  • 7
  • 56
  • 78
2

It is not possible to programmatically add custom fields to the iPhone address book, even in iOS 5.

Duncan Babbage
  • 19,972
  • 4
  • 56
  • 93
-1

Please check this out!

How to add a "Custom Label" to iOS AddressBook programmatically?

Working 100% in iOS 6. Tested!

Community
  • 1
  • 1
user1940888
  • 475
  • 1
  • 6
  • 11