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
1
vote
1 answer

How do i find the number of members of a CNGroup in Xcode 7/ iOS 9

I want to display the names of each of the CNGroups in an iPhone's contacts database, and the number of people in each group. I have the array of CNGroups, so I can get the name and the identifier properties of each group I could call [CNContact…
SimonTheDiver
  • 1,158
  • 1
  • 11
  • 24
1
vote
1 answer

Programmatically delete custom phone labels

In iOS it is possible to create custom labels for phone numbers and email addresses. Is there a way to remove those created labels programatically (either with CNContacts or ABAddressBook)? In other words: I don't want to delete the custom label…
hashier
  • 4,670
  • 1
  • 28
  • 41
0
votes
0 answers

How to fetch Contact Profile Picture in the relationships in SwiftUI?

I have successfully fetched all contacts and now I want to add a new feature that goes beyond the capabilities of the Apple Contacts app. However, I have also successfully fetched the CNContactRelationsKey. Here is the SwiftUI…
Antonio Adrian Chavez
  • 1,016
  • 1
  • 7
  • 12
0
votes
2 answers

Swift - how to Encode and Decode CNMutableContact array properly?

I am trying to make CNMutableContact "Codable". I have already built the encode function (see below), but I am getting some issues to decode array such as postalAddresses, emailAddresses, etc. Here is my encode function: public func encode(to…
Philippe
  • 5
  • 4
0
votes
0 answers

Parsing preferred phonenumbers with CNPhoneNumber from vcf-file

I try to parse a vcf-file. I use CNContact for this. That works quite well, but with the phonenumbers i have a problem. With CNLabeledValue* I get the label (e. g. "home") and the phonenumber in the value. Excerpt from the…
0
votes
0 answers

Is it possible to set the Text Tone for a contact in iOS?

I'd like to write an iOS app that reads all of the user's contacts and then sets the Text Tone for each contact to a specific vibration pattern. However I don't see Text Tone information available on the CNContact object. Is there any way to do what…
noahmoss
  • 105
  • 1
  • 6
0
votes
0 answers

Swift: Exporting VCF with X-IMAGETYPE:PHOTO & X-IMAGEHASH

I am trying to export VCF files from selected contacts with photos. I have a method to manually append the Base64 of the contacts photo to the vCard but, the file becomes unreasonably large when exporting many contacts with many photos. Does anyone…
Neo
  • 876
  • 1
  • 9
  • 25
0
votes
0 answers

CNContact object save/upload iCloud

This is code to encode [CNContact] array to NSData and upload to iCloud There are problem is a limit to upload information to iCloud( Text of error here Error: Optional(
0
votes
0 answers

How to get which action is called in CNContactViewController delegate?

I have implemented CNContactViewController to show phone number details controller. let store = CNContactStore() let contact = CNMutableContact() let homePhone = CNLabeledValue(label: CNLabelHome, value: CNPhoneNumber(stringValue :phNo…
Parth Patel
  • 915
  • 11
  • 33
0
votes
0 answers

I want to add address in a specific Phone Contact

I have a list of contacts in table view cell whenever I click a cell which is an existing contact I want to add or update address in that existing contact. var selectedContact: Contact! Contact! is a model var updateContact =…
0
votes
1 answer

It get crash when try to fetch the CNContact's Job Title and Profile Images

I have a lot of troubleshooting these issues a few days ago. Here the complete code, You need to create 2 Files. import Foundation import Contacts class contactsAspcts { var contactOut: CNContact init(contactOut: CNContact) { …
Antonio Adrian Chavez
  • 1,016
  • 1
  • 7
  • 12
0
votes
1 answer

How to show multiple phone numbers if exists in CNContactPickerViewController

in my app I am using CNContactPickerViewController for getting contacts. User can select multiple contacts so I implemented following delegate methods. func contactPicker(_ picker: CNContactPickerViewController, didSelect contacts: [CNContact]) { …
atalayasa
  • 3,310
  • 25
  • 42
0
votes
1 answer

Company field when enumerating contacts through CNContactStore

I'm fetching some contact fields using CNContactStore such as first name (CNContactGivenNameKey) and last name (CNContactFamilyNameKey) but I can't find the key for company. let request = CNContactFetchRequest(keysToFetch: [ CNContactGivenNameKey…
cbuchart
  • 10,847
  • 9
  • 53
  • 93
0
votes
1 answer

SwiftUI Fetching contacts duplication

I have a model view that has fetching contacts function: class ContactsStore: ObservableObject { @Published var contacts = [CNContact]() func fetch() {} ... And then in my View: @EnvironmentObject var store: ContactsStore var groupedContacts:…
Lina_F
  • 131
  • 2
  • 10
0
votes
1 answer

VCF in imessage crashing due to customized CNSocialProfile service name?

I have created a vcf programatically using swift . In this vcf i have made a [CNLabeledValue] object , on which i have appended a CNSocialProfile with custom service name , in my case its "Instagram" . But as soon as i share this…
SwiftNinja95
  • 157
  • 2
  • 16