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.
cncontact
258
questions
67
votes
8
answers
71k
views
Fetching all contacts in ios Swift?
I am aware of the ios swift has a Contacts Framework where I can fetch contacts, but I cannot find any method to fetch all the contacts together where I can access each of the contacts from that array....
46
votes
1
answer
2k
views
What is the ":ABPerson" string in CNContact identifier?
My iOS application checks the contacts from time to time and imports a new one to its own database.
I checked that contact and it already exists by the identifier field, that is usually filled by ...
35
votes
1
answer
11k
views
Error creating the CFMessagePort needed to communicate with PPT
I try to present a CNContactPickerViewController inside a SwiftUI application using the UIViewControllerRepresentable protocol. As I already read, there seems to be a known issue for this not working, ...
29
votes
7
answers
8k
views
CNContactViewController forUnknownContact unusable, destroys interface
[Appears to be fixed in iOS 10!] So what follows applies to iOS 9 only...
I have been experimenting with Apple's new Contacts framework, and I've found a huge bug in one of the three forms of ...
28
votes
3
answers
3k
views
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 ...
23
votes
1
answer
1k
views
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 ...
19
votes
4
answers
8k
views
iOS Swift CNContactPickerViewController search contact and add to selection
I am using iOS 9 and Swift 2.2
I have implemented iOS inbuilt CNContactPickerViewController using CNContactPickerDelegate to get the contact numbers,
In the CNContactPickerViewController Screen, ...
18
votes
2
answers
6k
views
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 '...
17
votes
3
answers
5k
views
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 ...
16
votes
4
answers
7k
views
How to add new email to CNMutableContact in Swift 3?
Quickly .. I have this code to add new contact , it was working until converting my code to Swift 3 , now it accept all properties except the email I get two errors :
1-Argument type 'String?' does ...
16
votes
3
answers
4k
views
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] ...
14
votes
3
answers
4k
views
CNContact last modified date and contacts changed
Questions:
How to get the last modified date in CNContact (new apple contacts framework) ?
The last modified date is not present in the list of keysToFetch
I would like to fetch and update contacts ...
13
votes
7
answers
2k
views
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. ...
13
votes
4
answers
25k
views
Swift Using Contacts Framework, search using phone number to get Name and User Image
I have an API that returns phone numbers in format: +1415xxxxxxx (E164)
Right now these numbers are put into a Cell of a UITableView and are presented as expected, however I'd like to be able to ...
13
votes
1
answer
2k
views
How to add custom hidden field in ios mobile contacts by CNMutableContact?
I want to add one custom hidden field in iOS mobile contacts from my application.
Is it possible to add the new hidden field with value in iOS mobile contacts? Will CNMutableContact allow me to add ...
12
votes
4
answers
6k
views
How to open New Contact Screen Directly?
Can any one please guide me ? Is it possible to open contact screen programmatically in iOS (swift)
11
votes
2
answers
7k
views
How to sort contacts using Contacts with Swift
I've read official apple documentation about sorting contacts, although I am not sure how to implement it.
So, here is fetch request:
let fetchRequest = CNContactFetchRequest(keysToFetch: keysToFetch)...
10
votes
2
answers
2k
views
How to get user sort order with CNContact API
I know that I can sort with CNContacts like this:
let fetch = CNContactFetchRequest(...)
fetch.sortOrder = .UserDefault
The question is: how do I find what is that sort order? Apart from some hacky ...
9
votes
3
answers
13k
views
how to retrive all CNContactStore from device without filter
I'm trying to insert into var contacts: [CNContact] = []
the var store = CNContactStore() but I did not find the right code for this job, i found this function that I need to give that a name
func ...
9
votes
2
answers
936
views
how to get new added contact identifier using CNContactStoreDidChangeNotification?
I want get all new added contact Identifier.
Here is my code :
-(void)viewWillAppear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(...
9
votes
0
answers
492
views
How do I make the search bar work with CNContactPicker when multiple selection is enabled?
I have project that is using the new Contacts framework introduced in iOS 9
Several of my UITableView subclasses call up a CNContactPicker and I wanted to make use of the search bar that appears at ...
8
votes
1
answer
2k
views
XCode8 Swift3 - Problems with open contact list and retrieve data by click
Currently I'm developing my first iOS App and I'm a little slow and rude about the code (it's so weird and different from java) and, if this was the only problem, with the new update, Xcode is making ...
8
votes
3
answers
2k
views
iOS 10, call directory extension not debugged
I am working on Call directory extension with callkit.
I selected Call directory extension for debug and when I run this target, no NSLog is shown.
How can I debug this extension?
ps : When I run ...
8
votes
3
answers
2k
views
How to check contact source in CNContact swift?
In Contact apps there's group like "iCloud", "yahoo", "gmail". In swift, is it possible to fetch contact from gmail source only?
8
votes
0
answers
381
views
Could we make our own CNContainer? swift
In this below image, google and yahoo could get their own CNContainer.
Could we make our own CNContainer like gmail and yahoo in these screenshot? If i could, how to do this?
7
votes
1
answer
4k
views
How to get localizedstring for CNLabeledValue in swift3
In swift 2 I'm using CNLabeledValue.localizedStringForLabel(phoneNumber.label) and works fine.
In swift 3 I tried this line CNLabeledValue.localizedString(forLabel: phoneNumber.label!) but got ...
7
votes
3
answers
9k
views
"Create New Contact" and "Add to Existing Contact" for CNContactViewController()
With ABAddressBook, when I wanted the user to be able to have the options of "Create New Contact" and "Add to Existing Contact" for a contact they hadn't seen before, I would create and present an ...
7
votes
5
answers
7k
views
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....
7
votes
2
answers
3k
views
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 ...
7
votes
3
answers
5k
views
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 ...
7
votes
2
answers
2k
views
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 ...
7
votes
2
answers
273
views
CNContacts framework possible bug with phone identifier?
Recently I have switched from old ABAddressBook framework to new CNContacts. In my project I synchronize contacts from native with my own core data contacts. For this I use contact identifier and ...
7
votes
2
answers
1k
views
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
...
7
votes
1
answer
2k
views
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 ...
7
votes
0
answers
301
views
Is it possible to customize CNContactPickerViewController?
I am new to iOS development and was wondering if I can modify CNContactPickerViewController tableViewCell such that the contacts who are already using my app are shown in somewhat a different way.
...
7
votes
3
answers
2k
views
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.
6
votes
1
answer
5k
views
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 ...
6
votes
2
answers
614
views
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 ...
6
votes
2
answers
1k
views
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 ...
6
votes
1
answer
2k
views
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 = ...
6
votes
2
answers
3k
views
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 = ...
6
votes
2
answers
660
views
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, ...
6
votes
1
answer
1k
views
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=(...
6
votes
1
answer
1k
views
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 ...
5
votes
2
answers
6k
views
iOS: get digits key from CNContact
I am using the Contact framework new to iOS 9 and I cannot figure out how to get the digits from the phoneNumbers key on a CNContact.
Doing an NSLog of the CNContact I get this output:
<CNContact:...
5
votes
1
answer
2k
views
How can I create a CNContact with a CNPostalAddress?
I tried this:
let contact = CNMutableContact()
contact.namePrefix = data["firstName"] as! String
contact.nameSuffix = data["lastName"] as! String
contact.organizationName = data["...
5
votes
1
answer
1k
views
Not able to create vcard of contacts using contact framework
I am using this code to export contact from ios phonebook to .vcf file. I have used this code for the task. But vcardString is always returning nil. Please help me to solve this issue.
NSMutableArray ...
5
votes
1
answer
949
views
CNContactPickerViewController with UIToolbar
How do I implement same contact picker as in iOS Apple Maps?
As you can see from pictures, in Maps app you can switch between favourites places and your contacts. I want switching between picker and ...
5
votes
1
answer
617
views
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 ...
5
votes
2
answers
497
views
How to reference external iOS system state updates in SwiftUI?
There are many possible variants of this question, but take as an example the CNAuthorizationStatus returned by CNContactStore.authorizationStatus(for: .contacts), which can be notDetermined, ...