Contacts

RSS for tag

Access the user's contacts and format and localize contact information using Contacts.

Contacts Documentation

Posts under Contacts tag

49 Posts
Sort by:
Post not yet marked as solved
0 Replies
57 Views
Hello I'm currently having some issues when using CNContactViewController in iOS 17. The problem starts after embedding the CNContactViewController inside a UINavigationController and presenting it modally. The CNContactViewController is created using the forNewContact initialiser and passing an initial value to it (CNMutableContact) Next I tap the Add Photo button, which presents the new iOS 17 Photo Editor/Picker which immediately covers all the screen. After pressing Cancel, the Photo Editor is dismissed but the "Go Home" gesture is disabled and its not possible to go to the Home Screen unless the iPhone screen is turned off and on again (this fixes the issue). This seems to be a bug in this CNContactViewController unless I'm using it incorrectly. Additionally, this is only happening when the Photo Editor is cancelled/dismissed. If the whole process of picking and editing a photo is completed, this issue does not happens and the "Go Home" gesture works as usual. Here is a code sample of how CNContactViewController being used and presented: class ContactViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let b = UIButton(type: .system) b.setTitle("Push", for: .normal) b.setTitleColor(.systemBlue, for: .normal) b.addTarget(self, action: #selector(pushAction(sender:)), for: .touchUpInside) b.translatesAutoresizingMaskIntoConstraints = false view.addSubview(b) NSLayoutConstraint.activate([ b.centerXAnchor.constraint(equalTo: view.centerXAnchor), b.centerYAnchor.constraint(equalTo: view.centerYAnchor) ]) } @objc func pushAction(sender: UIButton) { let mc = CNMutableContact() mc.givenName = "MyName" let vc = CNContactViewController(forNewContact: mc) vc.allowsActions = false vc.allowsEditing = false vc.contactStore = CNContactStore() vc.delegate = self let nc = UINavigationController(rootViewController: vc) nc.modalPresentationStyle = .fullScreen self.present(nc, animated: true) } } extension ContactViewController: CNContactViewControllerDelegate { func contactViewController(_ viewController: CNContactViewController, didCompleteWith contact: CNContact?) { viewController.dismiss(animated: true) } }
Posted
by diegoe.
Last updated
.
Post not yet marked as solved
1 Replies
221 Views
I have form fields in an app, I have some validations to perform like phone number should only have digits and not alphabets, however when user uses AutoFill option doing long press on textfield they have option to choose Contacts and they can tap on name and it will paste alphabets in my Phone number field, that behavior I don't want as my validations will not be fulfilled. There are no callbacks to detect and prevent that text from being pasted. In shouldChangeCharactersIn delegate method even if I return false for that paste event it ignores that and forcefully it gets pasted. Please help how to tackle such scenarios to perform above mentioned validations. Thanks
Posted Last updated
.
Post not yet marked as solved
0 Replies
151 Views
Hi everyone! It came to my knowledge from the documentation (https://developer.apple.com/documentation/contacts/cncontactstore/unifiedmecontactwithkeys%28tofetch:%29) that the method unifiedMeContactWithKeys(toFetch:), which fetches the me-card in the phone book by using CNContactStore, was recently made available for iOS as well. The problem is that I regardless get the error saying the method is unavailable for iOS, even though the documentation clearly states it should be available. I have tried several Xcode version including the latest one but to no avail... Does anyone have any idea what is wrong here? Kindest regards, Andreas
Posted Last updated
.
Post not yet marked as solved
0 Replies
132 Views
In the last two versions of beta 17.4, Siri has not been able to find a contact "Sandee" when I asked Siri to "Call Sandee" after years of finding that contact. I changed the spelling in my contacts to "Sandy" and then to "Sandra" and Siri found both when asking to call Sandy or Sandra.
Posted
by davetrnj.
Last updated
.
Post not yet marked as solved
0 Replies
153 Views
hi did anywhere have also the problem that he can not cannot contac the support over phone or emaili am receiving the message invalid email
Posted
by blaang.
Last updated
.
Post not yet marked as solved
0 Replies
220 Views
When I run my app there's lots of logging in the console appearing, with it appearing with my app's name as the process. My app is accessing contacts, however I'm not logging this, so is the OS? The thing is, I'm testing performance with contacts databases which have thousands of entries in them, not only is this logging cluttering up the console making it difficult to examine, but I think the logging of so many thousands of line is affecting performance. Where is it coming from? Can it be turned off?
Posted
by mungbeans.
Last updated
.
Post not yet marked as solved
0 Replies
252 Views
We are developing an app that uses the local contact search functionality. However, we are encountering an issue where some users are unable to search for local contacts using the contact's name or number input. Below is a code snippet from our project that uses the enumerateContacts() API from CNContactStore(): public func searchContacts(query: String, completion: @escaping SearchContactHandler) { let keysToFetch: [CNKeyDescriptor] = [ CNContactFormatter.descriptorForRequiredKeys(for: .fullName), CNContactPhoneNumbersKey as CNKeyDescriptor, ] DispatchQueue.global(qos: .userInitiated).async { [store] in do { var contacts: [PhoneContactInfo] = [] try store.enumerateContacts(with: CNContactFetchRequest(keysToFetch: keysToFetch)) { contact, _ in contacts.append(contentsOf: PhoneContactsFilter.filter(contact: contact, query: query)) } completion(.success(contacts)) } catch { completion(.failure(error)) } } } We have also tried to use the unifiedContacts() API from CNContactStore(): let storeContacts = try self.store.unifiedContacts( matching: searchNamePredicate, keysToFetch: self.keysToFetch ) var contacts: [PhoneContactInfo] = [] storeContacts.forEach { contact in contacts.append(contentsOf: PhoneContactsFilter.filter(contact: contact, query: query)) } completion(.success(contacts)) } We have considered the following factors: We always request local contact permission whenever the search is needed. searchContacts will be executed after permission is .authorized. The implementation details of PhoneContactsFilter.filter(contact: contact, query: query) can be considered correct cause it works in most of users. We tested one of the affected users and found that they were able to search for local contacts with the same code using a different app bundle ID (staging vs production). We would appreciate any insights on why some users are unable to search for local contacts with the input of the contact's name or number.
Posted
by Petergfq.
Last updated
.
Post not yet marked as solved
1 Replies
791 Views
We use Eventkit Framework to synchronize the meeting calendar to the system calendar, read the System Calendar with -[EKEventStore calendarsForEntityType:], Use - [EKEventStore saveEvent: span: commit: error:] wrote system calendar. This usage currently triggers the Contacts Permission Alert on a user. Through the log, we identified no use - [CNContactStore requestAccessForEntityType: completionHandler:] and Contacts API.
Posted
by zzjf.
Last updated
.
Post not yet marked as solved
1 Replies
221 Views
I am on iOS 17.2.1 Device: iPhone 15 Pro Sims: 1. Physical SIM (Secondary SIM) 2. eSIM (Primary SIM) In my phone settings, I have set the Default Voice Line to be 2. eSIM. This does not over ride the default Preferred Line that has got defined automatically for each contact. I have over 1000 contacts listed and its not at all feasible to open each saved contact and update the preferred line. This is in fact a bug and should be remediated so that the settings phone level should take the precedence.
Posted
by unixdoc.
Last updated
.
Post not yet marked as solved
0 Replies
227 Views
Dear Madam, Sir, I would like to ask why I can not have telephone call back for account and service and it says the red message as : We’re unable to make this call. Please reach out to us by email. Could you please guide me why I can not have telephone call support with call back for membership and account services ( before I use to be able to have call back in this section but now it says : We’re unable to make this call. Please reach out to us by email.). what should I do ? I can not also submit email form because the submit button does not work for my account ! Thank you so much Best Regards
Posted
by ingoampt.
Last updated
.
Post not yet marked as solved
1 Replies
376 Views
I'm having some problems accessing contacts inside of mac cli app. The main issue is that the app is not triggering a dialog requesting access to contacts. Some sources state that NSContactsUsageDescription should be added to info.plist. This info.plist is nowhere to be found inside the project in xcode. Then, some sources are stating that there was a xcode update, and now permissions are added on Targets -> Info tab, but this tab does not exist on mac cli project. Here is a code snippet: #import <Contacts/Contacts.h> int main(int argc, const char * argv[]) { @autoreleasepool { CNAuthorizationStatus status = [CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts]; if (status == CNAuthorizationStatusNotDetermined) { NSLog(@"Contact access not determined."); CNContactStore *contactStore = [[CNContactStore alloc] init]; [contactStore requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError * _Nullable error) { NSLog(@"Got response"); }]; } else if (status == CNAuthorizationStatusAuthorized) { NSLog(@"Access granted"); } else { NSLog(@"Access to contacts is denied or restricted."); } } return 0; } Running this outputs: Contact access not determined. and app exits with code 0. How would one access contacts inside of mac cli app project? Or setup proper permissions so that dialog would trigger? PS. I have also tried adding info.plist manually, but there was no difference. Maybe I did something wrong? Is info.plist even used in mac cli project?
Posted
by branisha.
Last updated
.
Post not yet marked as solved
0 Replies
269 Views
I have this issue FB13432607 where watchOS synced iCloud contacts just grow and grow and grow: I'm currently over 9 GB of contacts with many duplicate entries. iOS, iPadOS and macOS are also syncing the same iCloud contact store, and they're not showing this issue. I've been reporting feedback for some time, but then I thought, hey, I'm a developer, I can write a watchOS app! After the initial elation and some quick prototyping (it's not a huge amount of code), I came to see that CNSaveRequest is NOT supported on watchOS, which means I can't delete my contacts. (The other option is nuclear: erase all data, restore and re-sync). So writing an app is out, due to lack of API access. Which got me wondering: is my contact store growing because Apple also doesn't have an API to delete contacts on watchOS? If so, this is a huge issue. Any ideas?
Posted Last updated
.
Post not yet marked as solved
2 Replies
886 Views
I'm trying to remove a few languages which is present as the localized language in my app (under language section) in iTunes connect but when I try to remove it, it allows me to remove but when I try to save these changes Apple is prompting me an error message "You have one or more errors on this page. • An error has occurred. Try again later." Can anyone, please let me know how can I remove a localized language?
Posted Last updated
.
Post not yet marked as solved
0 Replies
473 Views
I'm able to get the access token by utilizing the "https://appleid.apple.com/auth/token" API. However, when obtaining contact data from the iCloud API at "https://api.icloud.com/contacts/v1/me/contacts" using the same access token. I'm not getting any response. I'm not sure whether the API is operational and live. Or please suggest if there any other API for fetching iCloud contacts. Additionally, I consistently receive a "invalid_scope" error when utilizing scope contacts with the "https://appleid.apple.com/auth/authorize" API.
Posted Last updated
.
Post marked as solved
1 Replies
513 Views
So I only recently uncovered the Contacts Framework through this video: https://youtu.be/sHKir2ZMk5Q. As such I'm not yet accustomed to the API. Basically my main problem is that I can't seem to find a way to access the name of the group a CNContact is in. The only support I can find is in Apple's own documentation, which isn't very helpful. if someone could point me in the right direction towards how to print the group name, I would be very grateful. My code is below, Cheers // ModelData.swift // B-Day import Foundation import Contacts import SwiftUI struct Contact: Identifiable { let id = UUID() let category: String let firstName: String let lastName: String let birthday: DateComponents? } func fetchAllContacts() async -> [Contact] { var contacts = [Contact]() let store = CNContactStore() let keys = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactBirthdayKey, CNContactIdentifierKey, CNGroupNameKey] as [CNKeyDescriptor] let fetchRequest = CNContactFetchRequest (keysToFetch: keys) do { try store.enumerateContacts(with: fetchRequest, usingBlock: { contact, result in //this should print the name of the contact's group print(contact.groupName) contacts.append(Contact(category: contact.groupName, firstName: contact.givenName, lastName: contact.familyName, birthday: contact.birthday)) }) } catch { print("Error") } return contacts }
Posted
by The-Wolf.
Last updated
.
Post not yet marked as solved
0 Replies
484 Views
This has been happening from 14.0 DB4 and has continued up to 14.2 DB1. Occurring on M2 MBA 13 and M2 MBP 16. The principle thing I noticed was searchpartyd running a bit more than one would expect. I understand this is a FindMy daemon. For context, it does a low level 2-5% CPU constantly, and is the number 3 ranked CPU Time process on both machines. In the launchd console log the following errors appear on continuous repeat: 2023-10-28 12:36:49.662855 (gui/501 [100017]) : denied lookup: name = com.apple.contactsd.persistence, requestor = Family[6697], error = 159: Sandbox restriction 2023-10-28 12:36:49.757132 : Last log repeated 1 times 2023-10-28 12:36:49.757107 (gui/501 [100017]) : denied lookup: name = com.apple.contactsd.persistence, requestor = searchpartyuser[6696], error = 159: Sandbox restriction 2023-10-28 12:36:51.307002 : Last log repeated 1 times 2023-10-28 12:36:51.306944 (gui/501 [100017]) : denied lookup: name = com.apple.contactsd.persistence, requestor = imagent[702], error = 159: Sandbox restriction For context: I do not have Family Sharing set up.
Posted
by Xenzo .
Last updated
.
Post not yet marked as solved
0 Replies
316 Views
I've been working with swift and swiftui for about a year (but I'm old so not so swift (sorry)). I am trying to construct a predicate other than those supplied in the framework (i.e., name, email, phone) to fetch contacts having a specific value in their socialProfiles. For example, I want to fetch all contacts having a urlString that contains a specific value. I've finding the documentation on NSPredicate to be a bit daunting, especially since I have never used Objective-C, only swift. I think the problem is I don't know how to refer to the socialProfiles value in the predicate format string, nor what operators I should be using to filter. I'm sure the code below is totally wrong, and I'm not sure it can even be done, but to help illustrate what I'm trying to do: keys = [CNContactSocialProfilesKey] as [CNKeyDescriptor] predicate = NSPredicate(format: "SELF.socialProfile.value.urlString contains %@", value) do { let contacts = try store.unifiedContacts(matching: predicate, keysToFetch: keys) return contacts } Any suggestions would be appreciated, including: "You can't do that...you've got to retrieve all the contacts and filter them yourself"
Posted
by dlshap.
Last updated
.
Post not yet marked as solved
0 Replies
281 Views
Hi, I'm trying to re-create the dial and text interactive buttons on the iOS 17 Contacts widget. Does anyone know how to trigger a phone call or a text message from an AppIntent? I've used the tel:***-***-xxxx before, but I can't see how to even open a url from a widget button. Any help would be greatly appreciated.
Posted Last updated
.
Post not yet marked as solved
2 Replies
420 Views
On our backend we detected imported contacts with strange identifiers, that looks like CNSuggestedContactStore://YnBsaXN0MDDUAQIDBAUGBwpYJHZlc...AAA. Inside of base64 encoded strictly service information like $archiver, CF$UID, internalEntityId, SGRecordId, $classname. I think that contact identifier always should be in uuid format isn't it? Do somebody know what this contacts are and how to obtain them for debug?
Posted
by ntyunin.
Last updated
.