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
2
votes
0 answers

CNContactView controller's cancel button disappears while typing and then reappears

I'm working with SwiftUI, I'm using a NavigationView, then a NavigationLink which takes to a UIViewControllerRepresentable of a CNContactViewController. UIViewControllerRepresentable: import SwiftUI import ContactsUI struct ContactView:…
2
votes
0 answers

Swift : read .vcf file from document directory?

We get .vcf from Document directory path but can't import to the device using .vcf file URL like '"Nik1 .vcf": …
2
votes
1 answer

Can't get the selected number from contactProperty

After spending many hours troubleshooting, searching and trying out some answers on StackOverFlow. I couldn't get this to work properly, I need to be able to select any number that a contact have, but I always get CNLabelPhoneNumberMain or in some…
Jessica Kimble
  • 493
  • 2
  • 7
  • 17
2
votes
0 answers

Fetching a contact from Contacts Framework is not working iOS 13

In my application I create a CNContact and save to the contacts store, I also save the contact's identifier. In another section of the app I use the identifier to fetch that contact but is not working in iOS 13. (This does works on iOS 12) Note: I…
Lucho
  • 1,024
  • 1
  • 15
  • 24
2
votes
0 answers

Newly added CNContact doesn't have unique identifier when fetched from native

When i try to add cncontact using saveRequest the identifier which I get from CNMutableContact is different from fetched contacts. To fetch all contacts for container in allContainers { let fetchPredicate =…
Priyanka M V
  • 111
  • 3
2
votes
1 answer

Cancel button has no effect for CNContactViewController

This is not a dupe of this question or this question because those answers didn't work. For some reason, the cancel button has no effect when presenting a CNContactViewController inside a UINavigationController. Steps to reproduce: Copy this view…
Crashalot
  • 33,605
  • 61
  • 269
  • 439
2
votes
2 answers

Reading Contact Part by Part (ios)

I have already read the contact using CNContact.framework, as follows let contactStore = CNContactStore() let keys = [CNContactEmailAddressesKey, CNContactPhoneNumbersKey, CNContactFormatter.descriptorForRequiredKeys(for:…
Ratul Sharker
  • 7,484
  • 4
  • 35
  • 44
2
votes
1 answer

How do I get only the first phone number from every contact on a device?

I have a table view that displays the names of all contacts on the device. These names are coming from an array called contactsArray. For each contact object I'm getting the phoneNumbers object and pulling the numbers into another array called…
Austin Berenyi
  • 1,013
  • 2
  • 13
  • 25
2
votes
0 answers

Camera screen showing blank black

I have a UIButton in my app name as "Add New Contact". When I click on this button It opens native new contact screen. but when I click on "add photo" in this native new contact screen, It have two option "Take Photo" and "Choose Photo". By clicking…
Ved Rauniyar
  • 1,539
  • 14
  • 21
2
votes
2 answers

CNContacts -- Address Line 2

How do we get the address line 2 for a specific contact address. I am able to successfully get the address line 1 using cnContact.postalAddresses.first?.value.street What property do we use to get the address line 2? Also, how do we prioritize the…
jayn
  • 45
  • 1
  • 8
2
votes
1 answer

How to Get updated/added/deleted contact using CNContactStoreDidChangeNotification

i made app using contact book contacts. Problem:- i update/add/delete contact from contact book then back to my app. My app applicationDidBecomeActive active write following code :- NotificationCenter.default.addObserver( self, …
2
votes
0 answers

Use device contacts as my chat application contact (like whatsapp)

I am developing an iOS chat application using Swift 3. When the app is launched for the first time it fetches all contact numbers from device using new Contacts API and sends those numbers to a server. The server returns a subarray of those numbers…
2
votes
0 answers

How to set up NSPredicate to exclude selection based on presence in an array?

I am setting up an app which allows a user to select a particular contact from their contacts. It is set up (and works) as follows: let contactStore = CNContactStore() var contactArray = [CNContact]() func selectContact(){ //This is called upon…
Runeaway3
  • 1,439
  • 1
  • 17
  • 43
2
votes
1 answer

How to set contact as a favorite contact programmatically in Swift?

I am developing an application in which I need to fetch all the contacts from device and then set it to favorite contact on button press. I am able to fetch all contacts using [CNContact] in iOS 9 and 10. But don't know how to set it as a favorite…
Nazrul Islam
  • 748
  • 8
  • 16
2
votes
0 answers

Searching Contacts using NSExpressions and NSPredicates

I've been able to filter a table of contacts by the contact's first name, last name, company, and notes. However, I also need to be able to search through the contact's postal addresses for the search terms. Has anyone worked with this before and…