如何将联系人导入我的应用程序
Posted
技术标签:
【中文标题】如何将联系人导入我的应用程序【英文标题】:How to import contacts into my app 【发布时间】:2015-12-30 08:31:39 【问题描述】:我需要在我的应用中访问我 iPhone 的通讯录。
我正在使用 Xcode 7.2 和 IOS-9。 给我最好的对我有用的框架或库。
我尝试使用 ABAddressbook 框架,但它已被弃用。
谢谢。
【问题讨论】:
***.com/questions/3747844/…的可能重复 Fetch Contacts in ios 7的可能重复 您可以使用联系人和联系人 UI 框架代替 ABAddressbook 框架阅读 iOS 9.0 中已弃用的 API。 【参考方案1】:Apple 引入了新框架 Contacts 和 ContactsUI 用于访问 iOS9 及更高版本的联系人。
以前的 ABAddressbook 框架已被弃用。您可能会在 SO 中找到很多关于此的信息。
您可以在 iOS9+ 设备上使用ContactsUI 框架
- (void) presentContacts
CNContactPickerViewController *contactPicker = [[CNContactPickerViewController alloc] init];
contactPicker.delegate = self;
[_myViewController presentViewController:contactPicker animated:YES completion:nil];
//Listen for delegates
- (void) contactPickerDidCancel: (CNContactPickerViewController *) picker
NSLog(@"didCancel");
- (void) contactPicker: (CNContactPickerViewController *) picker
didSelectContact: (CNContact *) contact
NSLog(@"didSelectContact"):
- (void) contactPicker: (CNContactPickerViewController *) picker
didSelectContactProperty: (CNContactProperty *) contactProperty
NSLog(@"didSelectProperty");
【讨论】:
【参考方案2】: CNContactPickerViewControllerhttps://developer.apple.com/library/ios/documentation/ContactsUI/Reference/CNContactPickerViewController_Class/
通讯录 ui 框架https://developer.apple.com/library/ios/documentation/AddressBookUI/Reference/AddressBookUI_Framework/index.html
MFMessageComposeViewController https://developer.apple.com/library/ios/documentation/MessageUI/Reference/MFMessageComposeViewController_class/
教程http://www.appcoda.com/ios-programming-import-contact-address-book/
http://gabriel-tips.blogspot.in/2012/02/how-to-import-contacts-from-address.html
【讨论】:
以上是关于如何将联系人导入我的应用程序的主要内容,如果未能解决你的问题,请参考以下文章