cncontactstore

How do I open the Contacts app Swift

百般思念 提交于 2021-02-05 08:25:27
问题 Is there a URL to open the contacts application from within my application? I know you can achieve this with the settings app by using the UIApplicationOpenSettingsURLString constant in Swift; however, I wasn't sure if I could do the same with the Contacts app. 回答1: There isn't a deep link for opening the Contacts App. Apple is very picky when it comes to deep-linking. They have to provide one for Settings since many apps need services like Data, Location, Bluetooth, Wifi, etc. Unfortunately

Fetch Contact Image - SwiftUI

ぃ、小莉子 提交于 2021-01-28 04:05:07
问题 I'm trying to fetch the image property of a given contact . Here's what I got: Model struct Contact: Identifiable { let contact: CNContact var id: String { contact.identifier } var image: Data? { contact.imageData } var givenName: String { contact.givenName } } static func fetch(_ completion: @escaping(Result<[Contact], Error>) -> Void) { let containerID = CNContactStore().defaultContainerIdentifier let predicate = CNContact.predicateForContactsInContainer(withIdentifier: containerID()) let

IOS 13 CNContacts No Longer Working To Retrieve All Contacts

不羁的心 提交于 2020-01-01 04:16:08
问题 I have an app that has worked perfectly well with the CNContacts framework all the way up to IOS 12. I'm currently testing it with IOS 13 beta and its completely broken. I've checked the contacts permissions and deleted the app and re-allowed the permissions. This is the code I'm using to retrieve all contacts: NSError* error; CNContactStore *store = [[CNContactStore alloc]init]; [store containersMatchingPredicate:[CNContainer predicateForContainersWithIdentifiers: @[store

How to force a new CNContact into a Local CNContainer?

六眼飞鱼酱① 提交于 2019-12-21 20:35:36
问题 I'm writing an app that stores contact-info fetched through REST and JSON into a container, using CNContactStore. I would like to keep these contacts separate from any other accounts, and only stored locally on the device, but a local store doesn't exist, and I can't find any way to create/activate one? I'm able to get the default store's ID (as configured on the device, e.g. iCloud), using: let store = CNContactStore() let containerID = store.defaultContainerIdentifier() ...and I can

create new group with contacts framework, CNErrorDomain Code = 2

别来无恙 提交于 2019-12-21 04:29:28
问题 i try to create and save a group with the Contacts Framework. First the user authorize the App for contacts access. A viewcontroller is presented and with a + button user shows an alertview with textfield. The user types the group name he wants and click to button of the alertview (save). This is the code for saving the new group. The group name is available but it is not possible to save this group anyway: CNContactStore *contactStore = [CNContactStore new]; [contactStore

CNContactStoreDidChangeNotification is fired multiple times

时间秒杀一切 提交于 2019-12-18 12:46:04
问题 I am able to observe the CNContactStoreDidChangeNotification when the contact database is changed while the app is in background state. I am pretty sure that only one observer was added to NSNotificationCenter . The problem is NSNotificationCenter posts MULTIPLE times (2, 3, 5, and even more times) even if I only add one new contact. Where is the problem? 回答1: Make certain you aren't adding the observer multiple times. This can happen without you realizing it if (for example) you call

How to fetch contacts NOT named “John” with Swift 3 [closed]

徘徊边缘 提交于 2019-12-13 09:33:54
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . Is there a way I can fetch contacts using the Contacts framework without an attribute? Example: myContactArray = unifiedContactsNotCalled("John") PS: I know that line is nothing like the real code, it's just a serving suggestion for illustrative purposes 😉 回答1: Before I outline

How to fetch iOS Contacts more quickly using Apple's Contacts framework having long list of contacts?

牧云@^-^@ 提交于 2019-12-07 15:39:51
问题 I am using CNContacts to fetch phonebook contacts in my iOS device. When I have a small number of contacts in my phone (say, 50) the contacts are fetched easily. However, when I have a lot of contacts (say 500-700) it hangs/waits for a long time to fetch these contacts from iOS phonebook into my App's array. Previously I used https://github.com/Alterplay/APAddressBook which was a fast library for the previous Apple framework, but now I am using the latest Apple framework. My code to fetch

CNContact add new contact issue

旧时模样 提交于 2019-12-06 09:43:40
问题 I'm faccing an issue at time of adding contacts throught Contact Framework . I used device iPhone 5s with iOS 12.1.2 My Code for adding contact is as below :: let saveRequest = CNSaveRequest() saveRequest.add(self, toContainerWithIdentifier: nil) do { try contactStore.execute(saveRequest) } catch let error { print("Error occurred while saving the request \(error)") } This everytime thows error as below :: Error occurred while saving the request Error Domain=CNErrorDomain Code=1 "Communication

How to retrieve all contacts using CNContact.predicateForContacts?

馋奶兔 提交于 2019-12-06 05:35:25
问题 So I have this code which works fine, but only if you have specified a name in the predicateForContacts parameter. func retrieveContactsWithStore(store: CNContactStore) { do { let predicate = CNContact.predicateForContacts(matchingName: "John") let keysToFetch = [CNContactFormatter.descriptorForRequiredKeys(for: .fullName), CNContactPhoneNumbersKey] as [Any] let contacts = try store.unifiedContacts(matching: predicate, keysToFetch: keysToFetch as! [CNKeyDescriptor]) self.objects = contacts