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
0
votes
1 answer

Presenting MFMessageComposeViewController/Understanding DispatchQueue.main.async

I'm trying to present the MFMessageComposeViewController after a person selects their contacts. But I'm getting the lldb error with the following message -- *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:…
0
votes
0 answers

How to clean contacts that get fetched from the iphone's contacts list?

What's the issue: Right now the contacts that are fetched might have a country code extension, for eg. it's 91 assuming it's an Indian contact. The problem arises when there's someone with a 0 as a country code or maybe even no country code. How do…
Ameya Vichare
  • 1,119
  • 1
  • 10
  • 22
0
votes
1 answer

select multiple properties from single contact in CNContactPicker

I am trying to use the CNContactPickerViewController and keep running into issues with how to pick multiple properties from a single contact Basic display of the picker let contactStore = CNContactStore() override func viewDidLoad() { …
0
votes
1 answer

set correct CNContact.predicateForContacts to select email

What is the correct way to set CNContact.predicateForContacts to select the field "email" in CNContacts? Like in SQL where email like "%lbs%"? This is my function to delete a lot of imported contacts I want to get rid of. But the function return 0…
Ralf Bordé
  • 333
  • 4
  • 18
0
votes
0 answers

how to remove countryCode from fetched Contacts in swift4?

func fetchContacts(){ let key = [CNContactGivenNameKey, CNContactPhoneNumbersKey] as [CNKeyDescriptor] let request = CNContactFetchRequest(keysToFetch: key) try! contactStore.enumerateContacts(with: request) { (contact, stoppingPointer)…
Sri Vathsav
  • 91
  • 1
  • 1
  • 3
0
votes
1 answer

Swift OSX CNContact.organizationName crash in High Sierra

My OSX app allows the user to select a contact from their contacts list and loads the details into a Customer record. I am using CNContactPicker to retrieve a contact into a CNContact record. One of the fields I need to retrieve is organizationName.…
0
votes
0 answers

Contact image data not saving

I have a phonelist application that loads employees from a database and lets users search through them. They have an option to add the contact to their phone. Currently I can add all of the data to the phone as a CNMutableContact(), but if I open…
g1231s49
  • 26
  • 6
0
votes
1 answer

Perform Segue called before dismiss ContactPicker

On didSelect of CNContachPicker I'm calling one segue but that is not working as when user clicks on any contact didSelect is first called then dismiss. How to handle such scenarios ? func contactPicker(_ picker: CNContactPickerViewController,…
Nitesh
  • 1,564
  • 2
  • 26
  • 53
0
votes
1 answer

Save CNContact in UserDefaults

I'm trying to save CNContact details into my UserDefaults but it fails. Any other way I could save CNContact ? struct User { var firstName: String = "" var lastName: String = "" var email: String = "" var phoneNumber: String = "" …
Nitesh
  • 1,564
  • 2
  • 26
  • 53
0
votes
1 answer

Swift 3: CNcontactpicker's phonenumber return 'not fetched' in device

our apps have a feature to get device contact, i have just used CNcontacpickerview it works when i run it on emulator, but when it run on device, the phonenumber return 'not fetched'. is it because my permission or what? the weird is it works on…
Benny Wijaya
  • 207
  • 3
  • 16
0
votes
1 answer

CNContact encoding of properties

I have a v-card string with the first name André and I initialise a CNContact with the v-card. BEGIN:VCARD VERSION:2.1 N:Foo;André;;; FN:André Foo TEL;CELL:00023 4474848 END:VCARD I initialise the contact with the raw string like this: if let…
Nico S.
  • 3,056
  • 1
  • 30
  • 64
0
votes
1 answer

Email CNContact as vCard

Is it possible to convert CNMutableContact as an vCard by email ? By below code I'm creating CNMutableContact and saving it to document directory but is it possible to send it directly instead of saving it? I don't need to save that. let contact =…
Nitesh
  • 1,564
  • 2
  • 26
  • 53
0
votes
1 answer

Modify a CNContact's properties in iOS

I have a User model item, and I want to use this User information to create a contact that can be shared through a UIActivityController. This is currently not possible because the properties of CNContacts are read-only: if let name =…
Cesare
  • 9,139
  • 16
  • 78
  • 130
0
votes
3 answers

Using swift am trying to get the index value of a particular label in an array of a phone number labels

I am attempting to get the index value of an array of CNLabelValue phone labels. I could iterate over them and get it that way but I know the .idex method would work just can't figure the syntax after of: let labelIndex =…
Jeremy Andrews
  • 807
  • 12
  • 17
0
votes
1 answer

Swift CNContacts

I am using a function to create a CNContact. Whenever I send a contact that does not have a phone number, it creates an error: fatal error: unexpectedly found nil while unwrapping an Optional value How do I send a nil string to my function?…
Ryan Hubbard
  • 247
  • 1
  • 5
  • 14