Contacts

RSS for tag

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

Contacts Documentation

Posts under Contacts tag

46 Posts
Sort by:
Post not yet marked as solved
0 Replies
643 Views
After presenting a CNContactViewController to create a new contact once I open the image editor and instead of going through the whole flow I decide the cancel it once I get back to my contact VC the cancel and done buttons are gone and I have no way to dismiss the contact info. Note: If you do go through setting an image at the end of the flow once you are back to the contacts VC the buttons are enabled again and the VC can be dismissed. Here's a quick code example of the presentation logic. This is all this app did. class ViewController: UIViewController { let button = UIButton(primaryAction: UIAction(handler: { _ in self.presentContacts() })) func presentContacts() { let mutableContact = CNMutableContact() let newPhone = CNLabeledValue(label: CNLabelPhoneNumberMobile, value: CNPhoneNumber(stringValue: "randomnumberhere")) mutableContact.phoneNumbers += [newPhone] let cont = CNContactViewController(forUnknownContact: mutableContact) cont.contactStore = CNContactStore() cont.allowsActions = false cont.isEditing = true cont.delegate = self let nav = UINavigationController(rootViewController: cont) nav.modalPresentationStyle = .fullScreen let navBarAppearance = UINavigationBarAppearance() navBarAppearance.configureWithTransparentBackground() nav.navigationBar.standardAppearance = navBarAppearance nav.navigationBar.scrollEdgeAppearance = navBarAppearance self.navigationController?.present(cont, animated: true) } } extension ViewController: CNContactViewControllerDelegate { func contactViewController(_ viewController: CNContactViewController, shouldPerformDefaultActionFor property: CNContactProperty) -> Bool { return false } func contactViewController(_ viewController: CNContactViewController, didCompleteWith contact: CNContact?) { viewController.dismiss(animated: true) } }
Posted
by
Post marked as solved
1 Replies
604 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
Post not yet marked as solved
0 Replies
399 Views
The application I am creating is using CNContact() and I am trying to attach an Instagram profile. There currently is no CNSocialProfileService for Instagram. Does anyone know of a way to do so? Currently I have: let socialProfile = CNLabeledValue(label: social.service, value: CNSocialProfile(urlString: "https://www.instagram.com/" + social.username, username: social.username, userIdentifier: nil, service: "Instagram")) That works but when it saves to contacts it creates a Custom Service and then capitalizes the service name and the username.
Posted
by
Post not yet marked as solved
0 Replies
422 Views
The documentation for hightlightProperty(withKey:identifier:) describes the parameter "key" as the "Key of the property to highlight." I believe that refers to the CNKeyDescriptor, such as CNContactGivenNameKey, which can cast from a type CNKeyDescriptor to String. The documentation for identifier is "the value to highlight". I believe an example of that would be "John" as the given name. Am I correct about all this? In any case, I'm not able to highlight an email property when I use CNContactEmailAddresses as the key, and an actual email address as the identifier. I have also tried using the identifier property of CNLabeledValue, which is how an email address is stored. I can't find anything on the internet to explain this. I didn't even find a similar question, except my own question asking this exact same question about two months ago. Anyone have any idea or a good answer for this?
Posted
by
Post not yet marked as solved
2 Replies
490 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
Post not yet marked as solved
0 Replies
344 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
by
Post not yet marked as solved
0 Replies
391 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
Post not yet marked as solved
0 Replies
605 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
Post not yet marked as solved
0 Replies
585 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
by
Post not yet marked as solved
0 Replies
344 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
by
Post not yet marked as solved
1 Replies
483 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
Post not yet marked as solved
0 Replies
333 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
Post not yet marked as solved
1 Replies
344 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
Post not yet marked as solved
0 Replies
343 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
Post not yet marked as solved
0 Replies
305 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
Post not yet marked as solved
0 Replies
240 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