Questions tagged [cncontactstore]

The CNContactStore class is a thread-safe class that can fetch and save contacts, groups, and containers.

The CNContactStore class is a thread-safe class that can fetch and save contacts, groups, and containers.

The CNContactStore class provides ways to execute fetch and save requests. There are a few recommended ways you can implement these requests in your app to load contacts:

Fetch only the contact properties that will be used.

When fetching all contacts and caching the results, first fetch all contacts identifiers, then fetch batches of detailed contacts by identifiers as required.

To aggregate several contacts fetches, first collect a set of unique identifiers from the fetches. Then fetch batches of detailed contacts by those unique identifiers.

If you cache the fetched contacts, groups, or containers, you need to refetch these objects (and release the old cached objects) when CNContactStoreDidChangeNotification is posted.

Because CNContactStore fetch methods perform I/O, it’s recommended that you avoid using the main thread to execute fetches.

117 questions
28
votes
3 answers

CNContactStoreDidChangeNotification is fired multiple times

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…
23
votes
1 answer

Contact Framework equivalent to ABAddressBook.ABAddressBookRegisterExternalChangeCallback

I am migrating an application from the deprecated Address Book Framework to the new Contacts Framework. The application utilizes ABAddressBookRegisterExternalChangeCallback to be notified when another application changes a contact. I am unable to…
me--
  • 1,978
  • 1
  • 22
  • 42
18
votes
2 answers

Which keys do I need for CNContactFormatter?

I'm trying to format a contact's name using the new CNContactFormatter. It looks like, I didn't fetch all needed name properties of the contact. Terminating app due to uncaught exception 'CNPropertyNotFetchedException', reason: 'A property was not…
flohei
  • 5,248
  • 10
  • 36
  • 61
17
votes
3 answers

IOS 13 CNContacts No Longer Working To Retrieve All Contacts

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…
Plasma
  • 2,622
  • 2
  • 20
  • 35
15
votes
3 answers

Fetch localized phone label using Contacts frameworks

I'm trying to fetch localized phone label value using CNContact.My attampt so far: NSError *error = nil; CNContactFetchRequest *fetchRequest =[[CNContactFetchRequest alloc] initWithKeysToFetch:keysToFetch]; [addressBook…
Poles
  • 3,585
  • 9
  • 43
  • 91
13
votes
7 answers

Keyboard overlaying action sheet in iOS 13.1 on CNContactViewController

This seems to be specific to iOS 13.1, as it works as expected on iOS 13.0 and earlier versions to add a contact in CNContactViewController, if I 'Cancel', the action sheet is overlapping by keyboard. No actions getting performed and keyboard is…
10
votes
0 answers

CNContactStore , Name.CNContactStoreDidChange

When the notification is posted for the CNContactStore has change, userinfo has three keys: CNNotificationOriginationExternally, CNNotificationSaveIdentifiersKey, and CNNotificationSourcesKey. I can not find any documentation as to the type of…
Stephen
  • 101
  • 5
8
votes
1 answer

Swift 3 / Xcode 8 - CNContact [access]

My code crashes as soon as it tries to request access to the CNContactStore. Any ideas if this is a beta issue? var addressBookStore = CNContactStore() addressBookStore.requestAccess(for: .contacts) { (granted, error) in // This console message is…
knappsimon
  • 113
  • 1
  • 8
7
votes
1 answer

What are the history-related Contacts framework class in iOS 13?

New in iOS 13 are a bunch of history-related classes such as CNChangeHistoryEvent and CNChangeHistoryFetchRequest. There's no documentation and they are not mentioned in any WWDC 2019 video that I can find. What are they for and how do I use them?
matt
  • 515,959
  • 87
  • 875
  • 1,141
7
votes
2 answers

How does iOS messaging apps like Viber, Telegram, WhatsApp fetch contacts so fast and efficiently

I don't know if this question qualifies to be here or not, but even after so much of research, I could not find a suitable guide for this question. I hope I get an answer here. I see that all the messaging apps like Viber, WhatsApp, Telegram fetch…
Dev_Bham
  • 97
  • 12
7
votes
2 answers

CNContactStore count of contact records

I need to get the number of all contacts on a user's device. The deprecation message on ABAddressBookGetPersonCount says: use count of fetch results for CNContactFetchRequest with predicate = nil Here is what I made up following that guidance: …
i-konov
  • 842
  • 1
  • 7
  • 19
7
votes
1 answer

create new group with contacts framework, CNErrorDomain Code = 2

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…
brush51
  • 5,691
  • 6
  • 39
  • 73
6
votes
1 answer

How to retrieve all contacts using CNContact.predicateForContacts?

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 =…
Chris Mikkelsen
  • 3,987
  • 9
  • 29
  • 41
6
votes
2 answers

iOS9 Contacts Framework get identifier from newly saved contact

I need the identifier of a newly created contact directly after the save request. The use case: Within my app a user creates a new contact and give them some attributes (eg. name, address ...) after that he can save the contact. This scenario is…
Thomas G.
  • 1,003
  • 12
  • 27
6
votes
1 answer

IOS CNContactStore executeSaveRequest fails with CNErrorDomain Code=500

When attempting to save a contact that has populated Social Profile data the following error is encountered: This is seen in iOS 9.2 Domain=CNErrorDomain,Code=500 "(null)" UserInfo={CNKeyPaths=(SocialProfiles), …
williamrct
  • 71
  • 1
  • 3
1
2 3 4 5 6 7 8