TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jul 2015 |
Maintained by Diego Pais.
MoABContactsManager is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "MoABContactsManager"
[[MoABContactsManager sharedManager] contacts:^(ABAuthorizationStatus authorizationStatus, NSArray *contacts, NSError *error) {
if (error) {
// An error has ocurred
}else {
if (authorizationStatus == kABAuthorizationStatusAuthorized) {
// Do something with contacts
}else {
// User didn't give permissions
}
}
}];
[[MoABContactsManager sharedManager] addContact:contact completion:^(NSError *error) {
// Do sometihng
}];
[[MoABContactsManager sharedManager] updateContact:contact completion:^(NSError *error) {
// Do something
}];
[[MoABContactsManager sharedManager] deleteContactWithId:contact.contactId completion:^(NSError *error) {
// Do something
}];
[[MoABContactsManager sharedManager] setSortDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"fullName" ascending:YES]]];
// Set MoABContactsManager delegate
[[MoABContactsManager sharedManager] setDelegate:self];
// Implement delegate
- (BOOL)moABContatsManager:(MoABContactsManager *)contactsManager shouldIncludeContact:(MoContact *)contact
{
// Only show contacts with phones
return [contact.phones count] > 0;
}
[[MoABContactsManager sharedManager] setFieldsMask:MoContactFieldFirstName | MoContactFieldLastName | MoContactFieldEmails | MoContactFieldPhones | MoContactFieldThumbnailProfilePicture];
NSLog(@"Serialized Contact: %@", [contact asDictionary]);
Output:
{
"contact_id" = 888;
"emails" =
(
{
"work" = "[email protected]"
},
{
"home" = "[email protected]"
}
);
"emails_values" =
(
"[email protected]",
"[email protected]"
);
"first_name" = John;
"last_name" = Doe;
"full_name" = "John Doe";
"phones" =
(
{
"mobile" = "+13121123345"
}
);
"phones_values" =
(
"+13121123345"
)
"addresses" =
(
{
"work" =
{
"City" = "Cupertino",
"Country" = "United States",
"CountryCode" = "us",
"State" = "CA",
"Street" = "1 Infinite Loop",
"ZIP" = "95014"
}
}
)
}
MoABContactsManager is available under the MIT license. See the LICENSE file for more info.