All Projects → SwiftyContacts → SwiftyContacts

SwiftyContacts / SwiftyContacts

Licence: MIT license
A Swift library for Contacts framework.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to SwiftyContacts

csv2vcf
🔧 Simple script in python to convert CSV files to VCF
Stars: ✭ 66 (-67.8%)
Mutual labels:  contacts, contacts-manager
Swiftycontacts
A Swift library for Contacts framework.
Stars: ✭ 171 (-16.59%)
Mutual labels:  watchos, contacts
contacts-android
Android Contacts API Library written in Kotlin with Java interoperability. No more ContentProviders and cursors. Say goodbye to ContactsContract. Build your own contacts app!
Stars: ✭ 298 (+45.37%)
Mutual labels:  contacts, contacts-manager
ContactsWrapper
Contacts wrapper for iOS 9 or upper with Objective-C
Stars: ✭ 22 (-89.27%)
Mutual labels:  contacts, contacts-wrapper
Apple-Platform-Security-Guides
Every Apple Platform Security Guide
Stars: ✭ 106 (-48.29%)
Mutual labels:  watchos
AsyncVoid
Project related to the site's posts about async void.
Stars: ✭ 32 (-84.39%)
Mutual labels:  async-await
await-lock
Mutex locks for async functions
Stars: ✭ 66 (-67.8%)
Mutual labels:  async-await
flying-apple
Just to keep track of nice content and new announcements related to Apple products and Swift
Stars: ✭ 45 (-78.05%)
Mutual labels:  watchos
wxapp-boilerplate
微信小程序开发脚手架 (ES6, Redux, Immutable-js, Async/await, Promise, Reselect, Babel, ESLint, Stylelint, Gulp ... )
Stars: ✭ 35 (-82.93%)
Mutual labels:  async-await
OpenAPI-ObjectiveC
KKBOX Open API Developer SDK for iOS/macOS/watchOS/tvOS
Stars: ✭ 19 (-90.73%)
Mutual labels:  watchos
node-mac-contacts
Create, read, update, and delete contacts from users' contacts databases on macOS.
Stars: ✭ 48 (-76.59%)
Mutual labels:  contacts
aioflask
Flask running on asyncio!
Stars: ✭ 192 (-6.34%)
Mutual labels:  async-await
Mechanica
A cross-platform library of Swift utils to ease your iOS | macOS | watchOS | tvOS and Linux development.
Stars: ✭ 27 (-86.83%)
Mutual labels:  watchos
WatchCon
WatchCon is a tool which enables creating easy connectivity between iOS and WatchOS.
Stars: ✭ 32 (-84.39%)
Mutual labels:  watchos
Rick-and-Morty-iOS-App
This is a sample iOS 13+ UIKit - Combine project.
Stars: ✭ 21 (-89.76%)
Mutual labels:  async-await
is-async-function
Is this a native `async function`?
Stars: ✭ 17 (-91.71%)
Mutual labels:  async-await
zookeeper
Apache ZooKeeper .NET async Client
Stars: ✭ 229 (+11.71%)
Mutual labels:  async-await
Columbus
A feature-rich country picker for iOS, tvOS and watchOS.
Stars: ✭ 23 (-88.78%)
Mutual labels:  watchos
yantra
JavaScript Engine for .NET Standard
Stars: ✭ 32 (-84.39%)
Mutual labels:  async-await
ionic3-awesome
😃 ionic3自定义组件及常用例子 演示地址
Stars: ✭ 95 (-53.66%)
Mutual labels:  contacts

SwiftyContacts

Language: Swift 5 Version License Platform Swift Package Manager Carthage compatible CocoaPods compatible RxSwift: Supported Read the Docs

A Swift library for Contacts framework.

Requirements

  • iOS 11.0+ / Mac OS X 10.13+ / watchOS 4.0+
  • Xcode 13.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate SwiftyContacts into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'SwiftyContacts'

Then, run the following command:

$ pod install

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but SwiftyContacts does support its use on supported platforms.

Once you have your Swift package set up, adding SwiftyContacts as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/SwiftyContacts/SwiftyContacts.git", .upToNextMajor(from: "4.0.0"))
]

Get started

async-await

Requests access to the user's contacts

let access = try await requestAccess()

Request the current authorization status

let status = authorizationStatus()
print(status == CNAuthorizationStatus.authorized)

Fetch all contacts from device

let contacts = try await fetchContacts()

Fetch contacts matching a name.

let contacts = try await fetchContacts(matchingName: "Satish Babariya")

Fetch contacts matching an email address.

let contacts = try await fetchContacts(matchingEmailAddress: "[email protected]")

Fetch contacts matching a phone number.

let contacts = try await fetchContacts(matching: CNPhoneNumber(stringValue: "+919426678969"))

To fetch contacts matching contact identifiers.

let contacts = try await fetchContacts(withIdentifiers: ["id1", "id2" ... ])

To fetch contacts matching group identifier

let contacts = try await fetchContacts(withGroupIdentifier: "")

find the contacts in the specified container.

let contacts = try await fetchContacts(withContainerIdentifier: "")

Fetch a contact with a given identifier.

let contact = try await fetchContact(withIdentifier: "")

Add contact to the contact store.

let contact = CNMutableContact()
contact.givenName = "Satish"
try addContact(contact)

Update contact to the contact store.

guard let contact = contact.mutableCopy() as? CNMutableContact else {
    return
}
contact.givenName = "Satish"
try updateContact(contact)

Delete contact to the contact store.

guard let contact = contact.mutableCopy() as? CNMutableContact else {
    return
}
try deleteContact(contact)

Adds a group to the contact store.

try addGroup("My Group")

Fetches all groups in the contact store.

let groups = try await fetchGroups()

Updates an existing group in the contact store.

guard let group = group.mutableCopy() as? CNMutableGroup else {
    return
}
try updateGroup(group)

Deletes a group from the contact store.

try deleteGroup(group)

Find the contacts that are members in the specified group.

let contacts = try fetchContacts(in: "My Group")

Add a new member to a group.

try addContact(contact, to: group)

Removes a contact as a member of a group.

try deleteContact(contact, from: group)

closures

Requests access to the user's contacts

requestAccess { result in
    switch result {
    case let .success(bool):
        print(bool)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Fetch all contacts from device

fetchContacts { result in
    switch result {
    case let .success(contacts):
        print(contacts)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Fetch contacts matching a name.

fetchContacts(matchingName: "Satish") { result in
    switch result {
    case let .success(contacts):
        print(contacts)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Fetch contacts matching an email address.

fetchContacts(matchingEmailAddress: "[email protected]") { result in
    switch result {
    case let .success(contacts):
        print(contacts)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Fetch contacts matching a phone number.

fetchContacts(matching: CNPhoneNumber(stringValue: "+919426678969")) { result in
    switch result {
    case let .success(contacts):
        print(contacts)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Fetch contacts matching contact identifiers.

fetchContacts(withIdentifiers: []) { result in
    switch result {
    case let .success(contacts):
        print(contacts)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Fetch contacts matching group identifier

fetchContacts(withGroupIdentifier: "") { result in
    switch result {
    case let .success(contacts):
        print(contacts)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Find the contacts in the specified container.

fetchContacts(withContainerIdentifier: "") { result in
    switch result {
    case let .success(contacts):
        print(contacts)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Fetch a contact with a given identifier.

fetchContact(withIdentifier: "") { result in
    switch result {
    case let .success(contact):
        print(contact)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Adds the specified contact to the contact store.

let contact = CNMutableContact()
contact.givenName = "Satish"
addContact(contact) { result in
    switch result {
    case let .success(contact):
        print(contact)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Updates an existing contact in the contact store.

guard let contact = contact.mutableCopy() as? CNMutableContact else {
    return
}
contact.givenName = "Satish"
updateContact(contact) { result in
    switch result {
    case let .success(contact):
        print(contact)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Deletes a contact from the contact store.

guard let contact = contact.mutableCopy() as? CNMutableContact else {
    return
}
deleteContact(contact) { result in
    switch result {
    case let .success(contact):
        print(contact)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Fetches all groups matching the specified predicate.

fetchGroups() { result in
    switch result {
    case let .success(groups):
        print(groups)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Adds a group to the contact store.

addGroup("My Group") { result in
    switch result {
    case let .success(group):
        print(group)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Updates an existing group in the contact store.

guard let group = group.mutableCopy() as? CNMutableGroup else {
    return
}
updateGroup(group) { result in
    switch result {
    case let .success(group):
        print(group)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Deletes a group from the contact store.

guard let group = group.mutableCopy() as? CNMutableGroup else {
    return
}
deleteGroup(group) { result in
    switch result {
    case let .success(group):
        print(group)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Find the contacts that are members in the specified group.

fetchContacts(in: "My Group") { result in
    switch result {
    case let .success(contacts):
        print(contacts)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Add a new member to a group.

addContact(contact, to: group) { result in
    switch result {
    case let .success(contact):
        print(contact)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Removes a contact as a member of a group.

removeContact(contact, from: group) { result in
    switch result {
    case let .success(contact):
        print(contact)
    case let .failure(error):
        print(error.localizedDescription)
    }
}

Author

Satish Babariya, [email protected]

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].