-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Pod::Spec.new do |s| | ||
s.name = "APAddressBook" | ||
s.version = "0.0.1" | ||
s.summary = "Easy access to iOS address book" | ||
s.homepage = "https://github.com/Alterplay/APAddressBook" | ||
s.license = { :type => 'MIT', :file => 'LICENSE.txt' } | ||
s.author = { "Alexey Belkevich" => "[email protected]" } | ||
s.source = { :git => "https://github.com/Alterplay/APAddressBook.git", | ||
:tag => s.version.to_s } | ||
s.source_files = 'Classes/**/*.{h,m}' | ||
s.ios.deployment_target = "5.0" | ||
s.requires_arc = true | ||
s.frameworks = 'AddressBook' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright (c) 2013 Alterplay | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,105 @@ | ||
APAddressBook | ||
============= | ||
============ | ||
|
||
#### About | ||
APAddressBook is a wrapper on [AddressBook.framework](https://developer.apple.com/library/ios/documentation/AddressBook/Reference/AddressBook_iPhoneOS_Framework/_index.html) | ||
|
||
--- | ||
|
||
#### Features | ||
* Load contacts from iOS address book asynchronously | ||
* Decide what contact data fields you need to load (for example, only first name and phone number) | ||
* Filter contacts to get only necessary records (for example, you need only contacts with email) | ||
* Sort contacts with array of any [NSSortDescriptor](https://developer.apple.com/library/mac/documentation/cocoa/reference/foundation/classes/NSSortDescriptor_Class/Reference/Reference.html) | ||
|
||
#### Installation | ||
Add `APAddressBook` pod to Podfile | ||
|
||
--- | ||
|
||
#### Using | ||
|
||
###### Load contacts | ||
```objective-c | ||
APAddressBook *addressBook = [[APAddressBook alloc] init]; | ||
// don't forget to show some activity | ||
[addressBook loadContacts:^(NSArray *contacts, NSError *error) | ||
{ | ||
// hide activity | ||
if (!error) | ||
{ | ||
// do something with contacts array | ||
} | ||
else | ||
{ | ||
// show error | ||
} | ||
}]; | ||
``` | ||
--- | ||
###### Select contact fields bit-mask | ||
Available fields: | ||
* APContactFieldFirstName - *contact first name* | ||
* APContactFieldLastName - *contact last name* | ||
* APContactFieldCompany - *contact company (organisation)* | ||
* APContactFieldPhones - *contact phones array* | ||
* APContactFieldEmails - *contact emails array* | ||
* APContactFieldPhoto - *contact photo* | ||
* APContactFieldDefault - *contact first name, last name and phones array* | ||
* APContactFieldAll - *all contact fields described above* | ||
Example of loading contact with first name and photo: | ||
```objective-c | ||
APAddressBook *addressBook = [[APAddressBook alloc] init]; | ||
addressBook.fieldsMask = APContactFieldFirstName | APContactFieldPhoto; | ||
``` | ||
|
||
--- | ||
|
||
###### Filter contacts | ||
The most common use of this option is to filter contacts without phone number | ||
Example: | ||
```objective-c | ||
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. | ||
```objective-c | ||
addressBook.sortDescriptors = @[ | ||
[NSSortDescriptor sortDescriptorWithKey:@"firstName" ascending:YES], | ||
[NSSortDescriptor sortDescriptorWithKey:@"lastName" ascending:YES] | ||
]; | ||
``` | ||
|
||
###### Check address book access | ||
```objective-c | ||
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; | ||
} | ||
``` | ||
|
||
--- | ||
|
||
#### Contacts | ||
|
||
[Check out](https://github.com/Alterplay) all Alterplay's GitHub projects. | ||
[Email us](mailto:[email protected]?subject=From%20GitHub%20APAddressBook) with other ideas and projects. |