0

I am doing the following to write Facebook and Twitter addresses to a new contact in the iOS addressbook:

ABMultiValueRef multiSocial = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
ABMultiValueAddValueAndLabel(multiSocial, (__bridge CFTypeRef)([NSDictionary dictionaryWithObjectsAndKeys:(NSString *)kABPersonSocialProfileServiceFacebook, kABPersonSocialProfileServiceKey, theFacebook, kABPersonSocialProfileUsernameKey, nil]), kABPersonSocialProfileServiceFacebook, NULL);
ABMultiValueAddValueAndLabel(multiSocial, (__bridge CFTypeRef)([NSDictionary dictionaryWithObjectsAndKeys:(NSString *)kABPersonSocialProfileServiceTwitter, kABPersonSocialProfileServiceKey, theTwitter, kABPersonSocialProfileUsernameKey, nil]), kABPersonSocialProfileServiceTwitter, NULL);
ABRecordSetValue(newPerson, kABPersonSocialProfileProperty, multiSocial, NULL);
CFRelease(multiSocial);

How do I extend this to create a "custom" entry for, say, a Google+ account name?

Thanks!

(This is an extension of my earlier question here: How to write Facebook/Twitter to address book in iOS?)

Community
  • 1
  • 1
Kent
  • 1,705
  • 3
  • 16
  • 26

1 Answers1

0

According to the ABPerson documentation,

The predefined constants are used to identify social networking services. You may use these constants or any other string.

Basically, this means that if you have a custom social profile for, say, stackoverflow, replace both occurrences of

kABPersonSocialProfileServiceFacebook

with

@"StackOverflow"

Note: bridging may be required

erdekhayser
  • 6,537
  • 2
  • 37
  • 69
  • Thanks! One problem though...seems to work great in simulator (iPad 7.1) but not on my live iPad! With the real iPad, none of the social items get saved to Contacts. :( – Kent Apr 13 '14 at 04:02
  • None including or excluding built in tags (e.g. Twitter, Facebook) – erdekhayser Apr 13 '14 at 05:04
  • No social info at all--built-in, or custom. On the simulator it works great...on the iPad the rest of my contact data gets generated (i.e. phone numbers, address, etc.) but not the social tagged stuff (i.e. Facebook, Twitter, custom Google+, custom Pinterest, etc.) – Kent Apr 13 '14 at 05:26
  • That is very strange. Try deleting the app off your iPad and press Cmd+K in Xcode before running again. – erdekhayser Apr 13 '14 at 19:15
  • I think it has something to do with the default group chosen in Settings. When I switch default group it works. Before it was an Exchange default group, now it's the local iOS one. I wonder if I can programatically force the group or even create a new one for my app's contacts (would be even better). Found this: http://stackoverflow.com/questions/11612781/programmatically-create-a-group-in-contacts – Kent Apr 13 '14 at 22:32