如何将自定义社交资料条目写入iOS通讯录? [英] How do I write a custom Social Profile entry to the iOS addressbook?

查看:330
本文介绍了如何将自定义社交资料条目写入iOS通讯录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做如下操作,将Facebook和Twitter地址写入iOS通讯录中的新联系人:

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

如何扩展这个以创建一个自定义条目,例如Google+帐户名称?



谢谢!



(这是我之前提到的问题的扩展:如何在Facebook中写Facebook / Twitter通讯录?

解决方案

根据ABPerson文档,



< blockquote>

预定义的常量用于识别社交网络服务。您可以使用这些常量或任何其他字符串。


基本上,这意味着如果您有一个自定义社交配置文件,例如,stackoverflow ,替换两次出现

  kABPersonSocialProfileServiceFacebook 

  @StackOverflow
/ pre>

注意:桥接可能需要


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?)

解决方案

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

这篇关于如何将自定义社交资料条目写入iOS通讯录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆