A modern, highly customisable contact picker with multi-selection options that closely resembles the behaviour of the ContactsUI's CNContactPickerViewController.
Single Deselect | Single Reselect | Multi Select |
Add this to your podfile for the latest version
pod 'KNContactsPicker'
Or specify desired version
pod 'KNContactsPicker', '~> 0.3'
Download and include the KNContactsPicker
folder and files in your codebase.
KNContactsPicker is a modern, customisable and easy to use Contacts Picker similar to the stock CNContactPickerViewController. It does improve in a couple of area for a better UX.
Coming soon:
Make sure your app (the host app) has provided a Privacy - Contacts Usage Description
in your Info.plist
.
It's also recommended that you check that contact authorisation is granted.
Implement the Delegate Methods
// This is in your application
extension ViewController: KNContactPickingDelegate {
func contactPicker(didFailPicking error: Error) {
print(error)
}
func contactPicker(didCancel error: Error) {
print(error)
}
func contactPicker(didSelect contact: CNContact) {
self.contacts.append(contact)
self.contactsTableView.reloadData()
}
func contactPicker(didSelect contacts: [CNContact]) {
self.contacts.append(contentsOf: contacts)
self.contactsTableView.reloadData()
}
}
Customise the Settings
var settings = KNPickerSettings()
settings.pickerTitle = "Pick"
settings.conditionToDisplayContact = { contact in
return contact.organizationName == "Apple"
}
settings.conditionToDisableContact = { contact in
return self.contacts.contains(contact)
}
Initialise and Present the KNContactsPicker
let controller = KNContactsPicker(delegate: self, settings: settings)
self.navigationController?.present(controller, animated: true, completion: nil)
You can use KNContactsPicker with KNContacts framework.
link |
Stars: 18 |
Last commit: 12 weeks ago |
This releases adds support for SPM.
In addition it adds a new option to select all displaying contacts with a Select all
button.
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics