1

how can i add a website to the contacts of the iphone/ipad address book? I managed to add email, phone numbers, but i cannot did the same with a site. Presently, i'm using this code to have the site written in the address book and displayed, but clicking on it i get displayed the form to write an email

        const CFStringRef siteLabel = CFSTR("Site");
        ABMutableMultiValueRef multiEmail = ABMultiValueCreateMutable(kABMultiStringPropertyType);
        ABMultiValueAddValueAndLabel(multiEmail, sito, siteLabel, NULL);
        ABRecordSetValue(newPerson, kABPersonEmailProperty, multiEmail, &error);
        CFRelease(multiEmail);
Sasha Grievus
  • 2,566
  • 5
  • 31
  • 58

2 Answers2

3

You need to use the kABPersonSocialProfileProperty property and kABPersonSocialProfileURLKey key.

e.g.:

    ABMutableMultiValueRef multiURL = ABMultiValueCreateMutable(kABPersonSocialProfileProperty);
    ABMultiValueAddValueAndLabel(multiURL, url, siteLabel, NULL);
    ABRecordSetValue(newPerson, kABPersonSocialProfileURLKey, multiURL, &error);
Paul Lynch
  • 19,769
  • 4
  • 37
  • 41
  • Unfortunately, as i launch this the Ipad crashesd. It said: Can't return type callbacks for 46 2013-01-23 11:17:59.357 Myapp[15926:907] -[__NSCFString count]: unrecognized selector sent to instance 0x1e8d4a00 2013-01-23 11:17:59.363 ForumPalermo[15926:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString count]: unrecognized selector sent to instance 0x1e8d4a00' libc++abi.dylib: terminate called throwing an exception – Sasha Grievus Jan 23 '13 at 10:18
  • Solved! Changin something here and there! Thank you! ABMutableMultiValueRef multiURL = ABMultiValueCreateMutable(kABMultiStringPropertyType); ABMultiValueAddValueAndLabel(multiURL, url, siteLabel, NULL); ABRecordSetValue(newPerson, kABPersonURLProperty, multiURL,&error); CFRelease(multiURL); – Sasha Grievus Jan 23 '13 at 10:24
1

Solved using the code by Paul, modified a little!

ABMutableMultiValueRef multiURL = ABMultiValueCreateMutable(kABMultiStringPropertyType);          
ABMultiValueAddValueAndLabel(multiURL, url, siteLabel, NULL); 
ABRecordSetValue(newPerson, kABPersonURLProperty, multiURL,&error); 
CFRelease(multiURL);
Sasha Grievus
  • 2,566
  • 5
  • 31
  • 58
  • I had a typo in my code - can't compile in my head yet! My reading is that you should be using kABPersonSocialProfileProperty, although your solution will work. Please also accept my answer :-). – Paul Lynch Jan 23 '13 at 12:25
  • it is allows return 0 until the user marge the Social contacts with native and this does not happened until he try to delete the Facebook account for example in that case alert appear and ask if u wanna to marge contacts or not ??? other wise return 0 values :) – Omarj Jan 31 '13 at 08:54