简体   繁体   English

如何在我的ios应用程序中共享联系人?

[英]How to share Contact in my ios App?

I would like to share any contact from my contact book using my custom chat app. 我想使用我的自定义聊天应用程序与我的联系人分享任何联系方式。 Is there a way to fetch file related to contact and send it to the server? 有没有办法获取与联系人相关的文件并将其发送到服务器?

I would like to avoid iterate over all possible properties of the contact, create dictionary and send it. 我想避免迭代联系人的所有可能属性,创建字典并发送它。 Can I fetch any file using iOS Contact Framework? 我可以使用iOS Contact Framework获取任何文件吗?

You can fetch all contracts in array using cncontactstore, array contains all contacts, you can convert return array to JSON and send it to server. 您可以使用cncontactstore获取数组中的所有合约,数组包含所有联系人,您可以将返回数组转换为JSON并将其发送到服务器。

let store = CNContactStore()
let contacts = try store.unifiedContactsMatchingPredicate(CNContact.predicateForContactsMatchingName("Appleseed"), keysToFetch:[CNContactGivenNameKey, CNContactFamilyNameKey])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM