Questions tagged [cncontact]

CNContact is a thread-safe class for Apple architectures (MacOS, iOS, watchOS, etc.) that represent an immutable value object for contact properties, such as the first name and phone numbers of a contact.

The contact class (CNContact) is a thread-safe, immutable value object of contact properties, such as the contact’s name, image, or phone numbers. The contact class is like NSDictionary; it has a mutable subclass CNMutableContact you can use to modify contact properties. For contact properties that can have multiple values, such as phone numbers or email addresses, an array of CNLabeledValue objects is used. The labeled value class is a thread-safe, immutable tuple of labels and values. Labels describe each value to the user, allowing differentiation such as home and work phone numbers. The Contacts framework provides some predefined labels and you can create your own custom labels.

256 questions
7
votes
3 answers

How to fetch only mobile numbers in swift using CNContacts?

I have some code to retrieve all the phone numbers in the users contacts, but would like to filter out only mobile numbers. Currently, I am just doing this by only adding numbers with a first digit of "+" or second digit of "7" to an array, as shown…
R_McVities
  • 179
  • 1
  • 9
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
7
votes
2 answers

Swift grab "My Card" CNContact

I can't seem to figure out how to grab a users "My Card" from contacts. I am developing a native Mac application using swift.
Kevin Mann
  • 167
  • 1
  • 9
7
votes
2 answers

Contacts framework raises exception on reading of imageData

I try to fetch imageData after refetching CNContact using unifiedContactWithIdentifier:keysToFetch:error: and CNContactImageDataKey in Objective-C. I'm using Xcode 7.0 building on iPhone 6 Plus with iOS 9.0.2. In runtime I always have the same…
mikthebig
  • 93
  • 1
  • 6
7
votes
5 answers

Extract email from CNContactProperty - iOS 9

I have an iOS app which needs access to the Contacts picker view controller in order to allow the user to select a contact property such as email address/ telephone numbers of imessage email addresses. The problem I am having right now, is that I…
Supertecnoboff
  • 6,406
  • 11
  • 57
  • 98
6
votes
1 answer

iOS: Use CNPostalAddressFormatter to show contact addresses with proper delimiter (e.g., comma) between sections

The Apple documentation suggests using CNPostalAddressFormatter to display addresses as a formatted string, which helps immensely with internationalization. This code: let postalString = CNPostalAddressFormatter.string(from: postalAddress.value,…
Crashalot
  • 33,605
  • 61
  • 269
  • 439
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

Saving Contact Address to Unified Contact results in (CNErrorDomain error 500)

There is an odd error in my application that I can't find any workarounds/fixes for. For some reason, I'm able to save an address to a contact that isn't unified with a social profile (Facebook, Twitter, etc). However, when I try to add an address…
Harish
  • 1,374
  • 17
  • 39
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
2 answers

is there a cross device CNContact identifier?

Is there any icloud identifier for a CNContact that I could persist and reuse across devices ? The idea would be to be able to pull that CNContact again from a different iOS device. Documentation doesn't say anything about that. I know the previous…
Edward Ashak
  • 2,411
  • 2
  • 23
  • 38
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
6
votes
2 answers

iOS9 - CNContactPickerViewController : pre-select contacts

I use the new CNContactPickerViewController to select contacts from the address book and use them in my app. When I press a button, I call this code: let contactPicker = CNContactPickerViewController() contactPicker.delegate = self …
Frederic Adda
  • 5,905
  • 4
  • 56
  • 71
6
votes
1 answer

CNContactStore executeSaveRequest failing with (CNErrorDomain error 2.)

I'm trying to remove redundancy of URLs to my application. This works well, if a single contact has several URLs. But if there are linked contacts, typically save operation fails with the message "The operation couldn’t be completed. (CNErrorDomain…
Nick Entin
  • 1,087
  • 8
  • 18
5
votes
1 answer

How would I check if a CNContact has changed since the last time my iOS app saved it in the contact store?

I would like to store data in the contact store that is part of CNContact. Is there a property of NSObject or CNContact that I can store the contents of a Data structure or NSDate object? I would like to be able to keep up with when a CNContact was…
daniel
  • 1,446
  • 3
  • 29
  • 65
1 2
3
17 18