/JLAddressBook

An iOS ABAddressBook wrapper to easily map contacts to CoreData (or any class) entities

Primary LanguageObjective-CMIT LicenseMIT

JLAddressBook

Version Platform

Requirements

iOS 7.0

Installation

JLAddressBook is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "JLAddressBook"

Usage

To run the example project; clone the repo, run pod install, then open JLAddressBookExample.xcworkspace.

All you need to do is create an entity type that conforms to this protocol

@protocol JLContact<NSObject>

@optional

@property(nonatomic, strong) NSString *firstName;
@property(nonatomic, strong) NSString *lastName;
@property(nonatomic, strong) NSArray *phoneNumbers;    // NSString's
@property(nonatomic, strong) NSArray *emails;          // NSString's
@property(nonatomic, strong) NSArray *addressBookIDs;  // NSNumbers's
@property(nonatomic, strong) UIImage *thumbnail;
@property(nonatomic, strong) UIImage *photo;

@end

and then use the JLCoreDataContactManager or define a contact manager to keep track of these entities yourself:

@protocol JLContactManager<NSObject>

@required

- (id<JLContact>)newContact;
- (NSArray *)existingContacts;

@end

then you call JLAddressBook syncContacts to update your contacts from the iphone address book

@interface JLAddressBook : NSObject

- (instancetype)initWithContactManager:(id<JLContactManager>)contactManager;

+ (BOOL)authorized;
+ (void)attemptToAuthorize:(AuthorizationBlock)block;

- (NSArray *)syncContacts;

- (UIImage *)photoForContact:(id<JLContact>)contact;
- (UIImage *)thumbnailForContact:(id<JLContact>)contact;

- (void)addContactToDevice:(id<JLContact>)contact;
- (void)addContactToDevice:(id<JLContact>)contact withPhoto:(UIImage *)photo;

@end

Author

Projects

Here is a list of iPhone apps utilizing this library:

Faysee - Faysee Homepage

License

JLAddressBook is available under the MIT license. See the LICENSE file for more info.