How do I write a custom Social Profile entry to the iOS addressbook?

流过昼夜 提交于 2019-12-11 19:46:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!