问题
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?)
回答1:
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
来源:https://stackoverflow.com/questions/23038691/how-do-i-write-a-custom-social-profile-entry-to-the-ios-addressbook