Welcome to the documentation for LjContactManager – a powerful and easy-to-use contact manager library for iOS.
Installation
To install LjContactManager in your iOS project, use one of the following methods:
CocoaPods
To integrate LjContactManager using CocoaPods, add the following line to your Podfile:
pod 'LjContactManager'
Carthage
With Carthage, add the following line to your Cartfile:
github "LjApps/LjContactManager"
Basic Usage
To use LjContactManager in your project:
Step 1: Import
In your Swift file, import LjContactManager:
import LjContactManager
Step 2: Request Authorization
Before accessing the user’s contacts, request their permission:
LjContactManager.shared.requestAuthorization { (status) in
if status == .authorized {
// Proceed with accessing the contacts
}
}
Step 3: Fetch Contacts
Once authorization is granted, fetch the user’s contacts:
LjContactManager.shared.fetchContacts { (contacts, error) in
if let contacts = contacts {
// Use the 'contacts' array containing the fetched contacts
}
}
Advanced Features
Filtering Contacts
You can filter the fetched contacts based on specific criteria:
LjContactManager.shared.fetchContacts(with: "John", completionHandler: { (contacts, error) in
// Handle the filtered 'contacts'
})
Adding a Contact
Add a new contact to the user’s address book:
LjContactManager.shared.addContact(firstName: "John", lastName: "Doe", phoneNumber: "1234567890")
Deleting a Contact
Delete a specific contact from the user’s address book:
LjContactManager.shared.deleteContact(contact: contactToDelete)
Updating a Contact
Update information for an existing contact:
LjContactManager.shared.updateContact(contact: contactToUpdate)
Summary
LjContactManager provides a simple yet powerful way to manage contacts in iOS applications. By following the basic usage and leveraging the advanced features, you can easily integrate contact management functionality into your app.