在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:Alterplay/APAddressBook开源软件地址:https://github.com/Alterplay/APAddressBook开源编程语言:Objective-C 87.7%开源软件介绍:APAddressBook is a wrapper on AddressBook.framework that gives easy access to native address book without pain in a head. Features
Objective-cInstallation via Cocoapods Add pod 'APAddressBook' Installation via Carthage Add to your Cartfile github 'Alterplay/APAddressBook' Run Warning for iOS 10.0 and after To protect user privacy, an iOS app linked on or after iOS 10.0, and which accesses the user’s contacts, must statically declare the intent to do so. Include the From here. Load contacts APAddressBook *addressBook = [[APAddressBook alloc] init];
// don't forget to show some activity
[addressBook loadContacts:^(NSArray <APContact *> *contacts, NSError *error)
{
// hide activity
if (!error)
{
// do something with contacts array
}
else
{
// show error
}
}];
Select contact fields bit-mask Available fields:
Example of field mask with name and thumbnail: APAddressBook *addressBook = [[APAddressBook alloc] init];
addressBook.fieldsMask = APContactFieldFirstName | APContactFieldThumbnail; Filter contacts The most common use of this option is to filter contacts without phone number. Example: addressBook.filterBlock = ^BOOL(APContact *contact)
{
return contact.phones.count > 0;
}; Sort contacts APAddressBook returns unsorted contacts. So, most of users would like to sort contacts by first name and last name. addressBook.sortDescriptors = @[
[NSSortDescriptor sortDescriptorWithKey:@"name.firstName" ascending:YES],
[NSSortDescriptor sortDescriptorWithKey:@"name.lastName" ascending:YES]
]; Load contact by address book record ID [addressBook loadContactByRecordID:recordID completion:^(APContact *contact)
{
self.contact = contact;
}];
Load contact photo by address book record ID [addressBook loadPhotoByRecordID:recordID completion:^(UIImage *image)
{
self.imageView.image = image;
}];
Observe address book external changes // start observing
[addressBook startObserveChangesWithCallback:^
{
// reload contacts
}];
// stop observing
[addressBook stopObserveChanges]; Request address book access [addressBook requestAccess:^(BOOL granted, NSError *error)
{
// check `granted`
}]; Check address book access switch([APAddressBook access])
{
case APAddressBookAccessUnknown:
// Application didn't request address book access yet
break;
case APAddressBookAccessGranted:
// Access granted
break;
case APAddressBookAccessDenied:
// Access denied or restricted by privacy settings
break;
} SwiftInstallation via Cocoapods pod 'APAddressBook/Swift' Import #import <APAddressBook/APAddressBook-Bridging.h> Installation via Carthage Add to your Cartfile github 'Alterplay/APAddressBook' Run Example See example application in self.addressBook.loadContacts(
{ (contacts: [APContact]?, error: Error?) in
if let uwrappedContacts = contacts {
// do something with contacts
}
else if let unwrappedError = error {
// show error
}
}) APContact serializationUse APContact-EasyMapping by Jean Lebrument 0.1.x to 0.2.x Migration guideHistoryContributor guideContactsIf you have improvements or concerns, feel free to post an issue and write details. Check out all Alterplay's GitHub projects. Email us with other ideas and projects. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论