Contacts

RSS for tag

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

Posts under Contacts tag

44 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

imageData property of CNContact
After setting the imageData property of CNContact through the API, I can see in the address book that the contact's avatar has been set to the imageData image, But when my phone version is iOS 17.1.0, when this contact calls in and locks the screen, I can see that this image is displayed in full screen, But when my phone version is iOS 17.5.1, when this contact calls in, the screen is locked and the image can only be displayed on the avatar, with a blurred image in the background, After iOS 17, contacts can set their avatars and posters separately in their contact list. How can I set these two images through code, just like setting the imageData property of CNContact through API. I see that there is a parameter in the CNContact property called _fullscreenImageData, but there is no value inside, and I am unable to obtain data for this parameter. I don't know how to manipulate this data in order to achieve the effect of setting up posters in the iOS 17.5.1 system.
1
0
332
Jul ’24
Get notified on 'Selected Contacts' updates
Is there a way for the application to get notified when user updates their 'Selected Contacts' from the Settings app when the Contacts permission on the application is set to the new iOS 18 CNAuthorizationStatusLimited status? My logic already listens for the CNContactStoreDidChangeNotification notification, but it doesn't look like it is being fired under this scenario. Do we have to setup a new CNChangeHistoryFetchRequest every time the application becomes active and compare the result? Is the value of the currentHistoryToken updated when user selects / deselects entries from their 'Selected Contacts'?
2
0
511
Jul ’24
iOS 18 Beta 2 XCTest: Unable to record and play contacts permission system dialog
Unable to record and play the new contacts permission system dialog. App: https://developer.apple.com/documentation/contacts/accessing-a-person-s-contact-data-using-contacts-and-contactsui func handleContactsAccessAlert() { let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") let allowButton = springboard.buttons["Allow Full Access"] allowButton.tap() let access6ContactsButton = springboard.alerts["Allow full access to 6 contacts?"].scrollViews.otherElements.buttons["Allow"] access6ContactsButton.tap() } func handleContactsPermissionAlert() { let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") let allowButton = springboard.buttons["Continue"] if allowButton.exists { allowButton.tap() sleep(5) handleContactsAccessAlert() } } func testContactPermissions() { let app = XCUIApplication() app.launch() app.buttons["Request Access"].tap() sleep(5) handleContactsPermissionAlert() sleep(5) app.collectionViews/*@START_MENU_TOKEN@*/.staticTexts["Kate Bell"]/*[[".cells.staticTexts[\"Kate Bell\"]",".staticTexts[\"Kate Bell\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap() }
3
1
697
Sep ’24
Issue with iPhone QR Code Contact Preview Displaying Email Instead of Organization
Post Content: Hi everyone, I’m encountering an issue with how iPhone displays contact information from a vCard QR code in the contact preview. When I scan the QR code with my iPhone camera, the contact preview shows the email address between the name and the contact image, instead of displaying the organization name. Here’s the structure of the vCard I’m using: BEGIN:VCARD VERSION:3.0 FN:Ahmad Rana N:Rana;Ahmad;;; ORG:Company 3 TEL;TYPE=voice,msg:+1234567890 EMAIL:a(at the rate)gmail.com URL:https://example.com IMPP:facebook:fb END:VCARD What I Expect: When I scan it with camera and in the contact preview before creating the camera I want organization name between name and image of the preview but I get email instead of ogrganization name. If only organisation is passed then it displays correctly but when I pass email it displayed email in between. Steps I’ve Taken: Verified the vCard structure to ensure it follows the standard format. Reordered the fields in the vCard to prioritize the organization name and job title. Tested with a simplified vCard containing only the name, organization, and email. Despite these efforts, the email address continues to be displayed in the contact preview between the name and the contact image, while the organization name is not shown as expected. Question: How can I ensure that the organization name is displayed correctly in the contact preview on iPhone when scanning a QR code? Are there specific rules or best practices for field prioritization in vCards that I might be missing? I would appreciate any insights or suggestions on how to resolve this issue. Thank you!
2
0
528
Jul ’24
iOS18 Contacts bug report
Dear developers, I am experiencing a bug with Contacts on my iPhone13 since downloading the beta. Some names in the listing of contacts do not correspond with their card once opened in the Contacts app. The option to share contacts in 3rd party apps has disappeared. Noticed specifically in WhatsApp where my contacts are no longer synced and no longer show against numbers. Best regards
1
0
473
Jul ’24
CNContact instantMessage field duplicates after serializaiton/deserialization
Hello folks, I stumbled upon a weird CNContact serialization problem. I use the Contacts framework to update the AIM field, which is one of the instantMessageAddresses within a single Contact. Here is the simplified code I used: func updateAIMFieldOn(contact: CNContact, aimValue: String) { do { guard let mutableContact = contact.mutableCopy() as? CNMutableContact else { logger.error("[CM] Couldn't update contact with aim \(aimValue)") return } var updatedAddresses = mutableContact.instantMessageAddresses updatedAddresses.append(CNLabeledValue(label: "", value: CNInstantMessageAddress(username: aimValue, service: CNInstantMessageServiceAIM))) mutableContact.instantMessageAddresses = updatedAddresses let saveRequest = CNSaveRequest() saveRequest.update(mutableContact) try CNContactStore().execute(saveRequest) logger.verbose("Contact's AIM updated successfully!") } catch { logger.error("Couldn't update contact") } } And after serializing the contact to data, and then deserializing, the contact got two AIM fields with the same value: X-AIM;type=pref:some:part:of_my_aim_value IMPP;X-SERVICE-TYPE=AIM;type=pref:some:part:of_my_aim_value Why does it work in this manner? Is it possible that ":" char causes that? Format of my aim username is {some:part:of_my_aim_value}. I didn't find any information in the docs. Thanks!
0
0
496
Jun ’24
Contact Note Entitlement Disappearing For 'Release' Build Configuration
A few months ago I requested access to the com.apple.developer.contacts.notes entitlement, which I now have access to. While running on 'Debug' build configuration, everything works as expected. When creating a 'Release' build, however, the entitlement does not appear to be included with the app, as the console reports that fetching the note for each contact fails. When I try to add the "Contact Notes" capability in Xcode, under the 'Release' tab in the project settings, the capability appears for a few seconds, then disappears when I move to a different tab and return. This does not happen for the 'Debug' configuration. Attempted Resolutions: Changing the signing configuraiton from 'Automatic' to 'Manual', using a manually generated provisioning profile. I manually inspected the provisioning profile using the terminal to ensure it included the entitlement. Creating a separate entitlement file with com.apple.developer.contacts.notes, adding it to the root of the project. Ensuring that the path to this file is correct on the 'Release' configuration. Ensuring 'Contacts Notes Field Access' is enabled under 'Additional Capabilities' in the Developer portal. Adding the capability on Xcode. Below is the inspector displaying the provisioning profile for the 'Debug' Configuration: And the following image below shows the inspector details for the 'Release' Configuration provisioning profile: When I use a manual provisioning profile and an entitlements file at the root of the project, Xcode displays this strange error:
3
0
712
Jun ’24
UIKit ContactsAccessButton?
Apple revealed the ContactsAccessButton in the WWDC24 session 10121: Meet the Contact Access Button. After watching the video, reading through the documentation as well as the sample code , I can only find a SwiftUI ContactsAccessButton. However, our code base is written largely in UIKit, and our team prefers to do complex work and customization with lists via UITableView as opposed to SwiftUI List. So we would greatly prefer to use a UIKit ContactAccessButton. Is there not a UIKit equivalent to ContactsAccessButton? If there is, where can we find it?
1
0
596
Jun ’24
[AppKit] CNPropertyNotFetchedException when using CNContactFormatter on CNContact retrieved from CNContactPicker
I am using CNContactPicker (with "CNContactKey.PostalAddresses" as "displayedKeys") to allow users to pick a contact + postal address. Upon selection, I am retrieving the postal address using CNPostalAddressFormatter - this works without problems. However, when trying to retrieve the contact name using CNContactFormatter, this only works when the contact type is "Person". When it is "company", the app crashes with "CNPropertyNotFetchedException Reason: A property was not requested when contact was fetched" (because the formatter attempts to access "organizationName", which it apparently can't. There also doesn't seem to be a way to "retrieve" this information without having to request contacts permissions manually. The same code (just using CNContactPickerViewController, but also without requesting contacts permissions) works without issue on iOS.
2
0
565
Aug ’24
Limited Access for Contacts like for Photos to prevent certain apps to collect our data.
Hi Everybody, I would like to see the feature, that allows us to limit the access for selected apps to get access to our Contacts. Especially apps like WhatsApp cannot be trusted, in my opinion, so I would love to see the possibility to prevent, that they just analyse our full Contact book and sell the data. With a limited access feature, we can at least decide, which information we wanna share with suspicious companys. What do you think and how could we reach the developers attention to get this with the next major update. Greetings from Europe
2
0
721
Jun ’24
CNContactViewController blocking Home gesture after presenting the "Add Photo" View Controller in iOS 17
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) } }
0
0
516
Mar ’24
Get user's own contact card with unifiedMeContactWithKeys(toFetch:)
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
1
0
606
May ’24
Disable AutoFill option in UITextField or have control over the text which is being pasted using that option.
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
2
2
1.5k
Mar ’24
Where's this contacts logging coming from?
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?
0
0
524
Feb ’24
Not able to search for local contacts with CNContactStore()
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.
0
1
562
Jan ’24
Selecting Default Voice Line does not work
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.
2
1
998
Jan ’24
We’re unable to make this call.
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
1
2
689
Jan ’24