Skip to content

The most simple way to get device's phone book in Swift.

License

Notifications You must be signed in to change notification settings

KennethTsang/AddressBookKit

Repository files navigation

AddressBookKit

Version License Platform Language

Requirements

iOS 8.0 or above

Installation

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

pod "AddressBookKit"

or

Copy AddressBookKit.swift and AddressBookDataType.swift into your project.

Usage

Ask for Contacts permission

AddressBookKit.requestPermission { [weak self] (success) -> Void in
	if success {
		// Success, read address book here...
		// Example:
		let phoneNumbers = AddressBookKit.plainContacts(.PhoneNumber)
	} else {
		// No Permission
	}
}

AddressBookKit.plainContacts() will returns an array of PlainContact. Example:

let phoneNumbers = AddressBookKit.plainContacts(.PhoneNumber)
let emails = AddressBookKit.plainContacts(.Email)

AddressBookKit.groupedContacts() will returns an array of GroupedContact. Example:

let phoneNumbers = AddressBookKit.groupedContacts([.PhoneNumber])
let emails = AddressBookKit.groupedContacts([.Email])
let phonesAndEmails = AddressBookKit.groupedContacts([.PhoneNumber, .Email])

What is PlainContact?

Varible Type Description
firstName String? First Name
middleName String? Middle Name
lastName String? Last Name
fullName String Full Name
value String A String representing phone number or email

What is GroupedContact?

Varible Type Description
firstName String? First Name
middleName String? Middle Name
lastName String? Last Name
fullName String Full Name
phoneNumbers [String] An array of phone numbers in this contact
emails [String] An array of Emails in this contact

Author

Kenneth Tsang, kenneth.tsang@me.com

License

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

About

The most simple way to get device's phone book in Swift.

Resources

License

Stars

Watchers

Forks

Packages

No packages published