In my app I export some data to the address book in order to create some new contact entries. I can export everything I want to without problem, except Facebook and Twitter add
Setting social profiles is very tricky for some reason, but here is the code necessary to doing so:
ABMultiValueRef multiSocial = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
ABMultiValueAddValueAndLabel(multiSocial, (__bridge CFTypeRef)([NSDictionary dictionaryWithObjectsAndKeys:(NSString *)kABPersonSocialProfileServiceFacebook, kABPersonSocialProfileServiceKey, theFacebook, kABPersonSocialProfileUsernameKey,nil]), kABPersonSocialProfileServiceFacebook, NULL);
ABRecordSetValue(newPerson, kABPersonSocialProfileProperty, multiSocial, NULL);
According to the documentation, the social profiles is a kABMultiDictionaryPropertyType, not kABMultiStringType.
That also means that you need to add dictionaries to multiSocial
, not strings. The format does not make sense to me for the dictionary, so just copy and paste whenever you need to use it.
Then, you set it how you did before.