Contacts

RSS for tag

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

Posts under Contacts tag

194 Posts

Post

Replies

Boosts

Views

Activity

EXC_BAD_ACCESS crash when enumerating contacts
Hi, I'm encountering a crash when attempting to enumerate contacts using a block-based enumeration method. The crash log shows an EXC_BAD_ACCESS error. I suspect the crash may be related to a memory management issue, but I'm having trouble pinpointing the exact cause. The crash have on Crashlytics but can not reproduce. Has anyone else encountered this issue or have any suggestions for troubleshooting this type of crash? Any help would be greatly appreciated. Thank you! Crash log: EXC_BAD_ACCESS (KERN_INVALID_ADDRESS) 0 libobjc.A.dylib 0x307c objc_retain_x8 + 16 1 Contacts 0x2c318 __52-[CNXPCDataMapper contactObservableForFetchRequest:]_block_invoke + 260 2 ContactsFoundation 0xc344 __26-[CNObservable doOnError:]_block_invoke + 320 3 ContactsFoundation 0xc728 __31-[CNObservable doOnCompletion:]_block_invoke + 320 4 ContactsFoundation 0xc728 __31-[CNObservable doOnCompletion:]_block_invoke + 320 5 ContactsFoundation 0xc344 __26-[CNObservable doOnError:]_block_invoke + 320 6 ContactsFoundation 0x8048 __27-[CNObservable doOnCancel:]_block_invoke + 252 7 ContactsFoundation 0xbb88 -[CNObservable enumerateObjectsUsingBlock:] + 404 8 Contacts 0xb48f8 __91-[CNDataMapperContactStore enumerateContactsAndMatchInfoWithFetchRequest:error:usingBlock:]_block_invoke.61 + 552 9 Contacts 0x315c4 __38-[_CNContactsLogger fetchingContacts:]_block_invoke_2 + 44 10 libsystem_trace.dylib 0xa108 os_activity_apply_f + 88 11 Contacts 0x221fc -[_CNContactsLogger fetchingContacts:] + 248 12 Contacts 0x2149c -[CNDataMapperContactStore enumerateContactsAndMatchInfoWithFetchRequest:error:usingBlock:] + 528 13 Contacts 0x21174 -[CNContactStore pool_enumerateContactsWithFetchRequest:error:usingBlock:] + 268 14 Contacts 0x22ab0 -[CNContactStore enumerateContactsWithFetchRequest:error:usingBlock:] + 492 Source code: @synchronized (contactStore) { @try { [contactStore enumerateContactsWithFetchRequest:listKeyToFetch error:&error usingBlock:^(CNContact* cnContact, BOOL* stop) { Contact *contact = [Contact newWithCNContact:cnContact]; if (filter(contact)) { [contacts addObject:contact]; } }]; } }
3
0
1.3k
Mar ’23
NSCocoaErrorDomain Code=134092 When Updating ContactsError, and Error "Attempt to read notes by an unentitled app" while I am not request for notes
Hi, I'm writing a command line program with Swift Package Manager that uses Contacts API to automatically add phonetic names for the contacts. However, I found I was unable to do so for contacts that has notes. First, when I was trying to enumerate the contacts, there is a strange error output: 2023-01-22 18:58:36.085525+0800 PhoneticNames[18591:98356] [core] Attempted to register account monitor for types client is not authorized to access: {( "com.apple.account.CardDAV", "com.apple.account.Exchange", "com.apple.account.LDAP" )} 2023-01-22 18:58:36.085580+0800 PhoneticNames[18591:98356] [accounts] CNAccountCollectionUpdateWatcher 0x6000003ccc40: Store registration failed: Error Domain=com.apple.accounts Code=7 "(null)" 2023-01-22 18:58:36.085606+0800 PhoneticNames[18591:98356] [accounts] CNAccountCollectionUpdateWatcher 0x6000003ccc40: Update event received, but store registration failed. This event will be handled, but the behavior is undefined. 2023-01-22 18:58:36.136236+0800 PhoneticNames[18591:98344] [api] Attempt to read notes by an unentitled app According to this document, I need to add the notes entitlement only if I was requesting the note field with CNContactNoteKey. However, I was not requesting it and I still get that "Attempt to read notes by an unentitled app" error. Here is my code for enumerating the contacts: let keys: [CNKeyDescriptor] = [CNContactFormatter.descriptorForRequiredKeys(for: .fullName), CNContactFormatter.descriptorForRequiredKeys(for: .phoneticFullName)] let fetchRequest = CNContactFetchRequest(keysToFetch: keys as [CNKeyDescriptor]) fetchRequest.mutableObjects = true do { try store.enumerateContacts(with: fetchRequest) { (contact, stop) in contacts.append(contact.mutableCopy() as! CNMutableContact) } } catch { print("unable to list contacts. \(error)") } And this is how I update the contacts later: let saveRequest = CNSaveRequest() contact.phoneticFamilyName = phoneticFamilyName contact.phoneticMiddleName = phoneticMiddleName contact.phoneticGivenName = phoneticGivenName saveRequest.update(contact) do { try store.execute(saveRequest) } catch { print("Fail to execute store request: \(error)") } This code works as expected for contacts without the note field. But for contact with a non-empty note field, the saveRequest fails and outputs the following error: 2023-01-22 18:58:36.197026+0800 PhoneticNames[18591:98344] [error] error: Unhandled error occurred during faulting: Error Domain=NSCocoaErrorDomain Code=134092 "(null)" ({ }) CoreData: error: Unhandled error occurred during faulting: Error Domain=NSCocoaErrorDomain Code=134092 "(null)" ({ }) 2023-01-22 18:58:36.201308+0800 PhoneticNames[18591:98344] [plugin] CDX_AB_GetGroupCollectionPath: nil group 2023-01-22 18:58:36.201353+0800 PhoneticNames[18591:98344] [plugin] CDX_AB_GetGroupCollectionPath: nil group In debugging mode inside Xcode, the contact will still be updated with phoetic names. But if I execute the compiled release binary in terminal, the output will be: CoreData: error: Unhandled error occurred during faulting: Error Domain=NSCocoaErrorDomain Code=134092 "(null)" ({ }) Fail to execute store request: Error Domain=NSCocoaErrorDomain Code=134092 "(null)" UserInfo={NSUnderlyingException=Unhandled error (NSCocoaErrorDomain, 134092) occurred during faulting and was thrown: Error Domain=NSCocoaErrorDomain Code=134092 "(null)", NSUnderlyingError=0x600002ee05d0 {Error Domain=NSCocoaErrorDomain Code=134092 "(null)"}} The contact will not be updated in this case. I looked for all the documents but couldn't find anything about NSCocoaErrorDomain Code 134092. Can you please give me some clues about the aforementioned behaviors?
2
2
2.2k
Mar ’23
Issue with contacts synchronization
Hi, we are building an app to sync contacts for event organization. The app can sync between 100 to 1000 contacts to the Contacts app of iOS. We can't manage the device because the user can bring their own device. We are currently facing an issue with thirdparty application like Whatsapp/Signal/Telegram because they sync the contacts from and to the phone. When the sync is enabled in one of this app we can't delete all the contacts at the end of the event because they are synced back to the Contacts app. When we update the contact it also get messed up by those apps. Do you know an workaround to prevent this scenario? Is it possible to prevent thos apps to sync a contact?
0
0
556
Feb ’23
escaping and non-escaping closure error in contact request
I get the error "Escaping closure captures non-escaping parameter 'completionHandler'" for the following code. I tried to add @escaping, but I honestly don't really get where and how. Did anybody had a similar problem and could help. Thank You!                 if access {                     completionHandler(access)                 }                 else {                     if authorizationStatus == CNAuthorizationStatus.denied {                         DispatchQueue.main.async {                             let message = "\(accessError!.localizedDescription)\n\n\(NSLocalizedString("Bitte ändere dies in den Gerät Einstellungen.", comment: ""))"                             self.showMessage(message: message, controll: controll)                         }                     }                 }             })
2
0
863
Feb ’23
Drag and Drop Contacts not working in Ventura
This code was working fine in Monterey but since upgrading to Ventura it no longer works: let contactsUTTypes = [UTType.vCard, UTType.contact] func performDrop(info: DropInfo) -> Bool {     print (info)     let items = info.itemProviders(for: contactsUTTypes)     print (items)     for item in items     {         item.loadDataRepresentation(forTypeIdentifier: UTType.vCard.identifier, completionHandler: { (data, error) in             if let data = data,                let contact = try? CNContactVCardSerialization.contacts(with: data).first             {                 print("Contact: \(contact.givenName)")             }         })     }     return true } let items = info.itemProviders(for: uttypes) always returns zero items Has this been broken in Ventura or do I need to do this differently now?
2
0
969
Feb ’23
App contacts
There are 2 things that I do not quite understand about the apple operating system and that every year is updated to a new version, supposedly with improvements, and that these two issues that are day to day and that all people use at all times. One of them is the contacts app, can someone tell me why it has not been developed the possibility of being able to sort my contacts by several fields other than first and last name, for example COMPANY. Everyone can have several of the same names, for example, juan. But from different companies, and this information does not appear neither in the list of contacts nor as a possibility to sort. IT'S UNBELIEVABLE! So many cutting edge updates and improvements and this is still the same since the first day almost 20 years ago. thanks
4
0
1.1k
Feb ’23
Rate Limit Exceeded for CardDAV connections
We've been supporting iCloud CardDAV contacting syncing for over 8 years. Never once had a problem before, but past week or so we've had numerous reports from users where they're seeing "Rate Limit Exceeded" errors coming from iCloud. What are these limits? How can developers request for an increase (where users genuinely import hundreds of new contacts daily)? Google contacts, for instance, allows developers to apply for an increase. There seems to be nothing in relation to this in the documentation. We have no clue what these limits even are.
3
7
1.6k
Feb ’23
What size image should be added to a contact such that it appears in full screen mode on the incoming call screen?
I'm programmatically adding a contact with an image with the intention the image should display in full screen size when a caller matching the number of the contact calls (as opposed to the image appearing as a tiny round icon next to the caller name). I'm creating an image of the same size and scale factor as the iPhone, and so far its working out ok - I have about 15 different phones, of various dimensions and scale factors, ranging from an old iPhone mini up to the most recent iPhone Pro Max, and on all of these it works as intended. But there's an exception, an iPhone 12 Pro (which has dimensions 390 * 844 and scale factor 3), on this phone when there is a call the contact image appears as a tiny icon. Why. Why is this phone different? How can I know what size image should be added to a contact to appear at full size in the call screen when every phone has different dimensions and they are not behaving the same? Additional question - the iPhone applies some cropping and expansion to whatever image gets added, is it possible to know what's being done to the image in order to make it display perfectly? (i.e. if the image contains some text, the fact the OS crops away some of the edge of the image, then expands what's left to fill the screen dimensions results in some pixelation)
0
0
647
Feb ’23
iCloud CardDAV API - FN property (vCard) sometimes empty
The iCloud CardDAV interface occasionally returns vCards with empty FN value (https://www.rfc-editor.org/rfc/rfc6350#section-6.2.1). The behavior seems to occur only since a few months (noticed by customer reports of our CardDAV client). here is an example vCard: BEGIN:VCARD VERSION:3.0 FN: N:LastName;Firstname;;; UID:.vcf PRODID:-//Apple Inc.//iCloud Web Address Book 2304B11//EN REV:2023-01-03T17:21:11Z ORG:; TEL;TYPE=HOME:<phone_nr> END:VCARD After a resynchronization of the contact data, the vCards with empty "FN" values seem to vary (other contacts are affected by that issue than before). Everything seems to be fine on the iCloud website or in the iPhone contacts app.
0
0
1.2k
Feb ’23
Adding Contact to Device Contacts app crashing in macOS ventura
We are using CNSaveRequest in CNContactStore to add contacts to system device contacts. But when calling execute method the app crashing in internal libraries.The code was working fine until macOS Monetery, In macOS Ventura beta we are facing this issue. Sample Code: let store = CNContactStore() store.requestAccess(for: .contacts, completionHandler: { isSuccess,error in guard isSuccess else { return } let contact = CNMutableContact() contact.familyName = "Hello" contact.givenName = "Contact" let request = CNSaveRequest() request.add(contact, toContainerWithIdentifier: nil) do { try store.execute(request) } catch { print(error) } }) Crash:
5
2
2.7k
Feb ’23
How should you programatically add a contact so it remains only on the device and isn't synched to iCloud?
I want to programmatically add a contact, preferably within its own group, such that it remains only on the (iPhone) device local copy of contacts and doesn't get synched elsewhere. However if I programmatically create a group then the group itself appears in iCloud, so presumably contacts within it will to. What sort of arrangement of containers/groups/contacts etc. should I create to achieve this?
0
0
1.3k
Jan ’23
Parsing preferred phonenumbers with CNPhoneNumber from vcf-file
I try to parse a vcf-file. I use CNContact for this. That works quite well, but with the phonenumbers i have a problem. With CNLabeledValue&lt;CNPhoneNumber*&gt;* I get the label (e. g. "home") and the phonenumber in the value. Excerpt from the vCard: TEL;TYPE=home:1234567890 But if the number is tagged with a "pref" i can't get this tag for the phonenumber. Excerpt from the vCard: TEL;TYPE=home,pref:0987654321 Is there anyway to find out, which numbers are the preferred numbers? I use following code: for (CNLabeledValue&lt;CNPhoneNumber*&gt;* number in cnContact.phoneNumbers) { NSString *label = number.label; NSString *number = ((CNPhoneNumber*)number).stringValue; //Do some work with label and number }
0
0
743
Jan ’23
How do I create & update CNContacts on macOS?
My attempts at creating a new CNContact fail with error message EXC_BAD_ACCESS (code=1, address=... at runtime Attempting to update an existing record appears to change the CNContact record, but the change is not visible in Apple's Contacts app. Code: Code I have so far: var status: Bool = false store.requestAccess(for: CNEntityType.contacts) { hasPermission, error in if error != nil { print(error!) } status = hasPermission } let newContact = CNMutableContact() newContact.givenName = "NBED-given" newContact.familyName = "NBED-family" let saveRequest = CNSaveRequest() saveRequest.add(newContact, toContainerWithIdentifier: store.defaultContainerIdentifier()) do { try store.execute(saveRequest) } catch { print("Error:\t\(error)") } ... and ... guard let contact = contactToAmend.mutableCopy() as? CNMutableContact else { return } contact.givenName = "NEW NAME" let saveRequest = CNSaveRequest() saveRequest.add(contact, toContainerWithIdentifier: store.defaultContainerIdentifier()) do { try store.execute(saveRequest) print("Stored ok") } catch { print("Error:\t\(error)") } Looking up this Contact in the Contacts app, I can search for it with the new given name ("NEW NAME"), but the record is then shown with its old (unchanged) name. It's also worth adding that I am seeing a number of messages / warnings in XCode during runtime: 2023-01-06 14:17:45.628226+0000 [api] Attempt to read notes by an unentitled app 2023-01-06 14:17:54.164223+0000 Metal API Validation Enabled 2023-01-06 14:17:54.436906+0000 [api] Attempt to write notes by an unentitled app CoreData: warning: Unable to load class named 'ContactsPersistence.CNEWSContactFolder' for entity 'ContactFolder'. Class not found, using default NSManagedObject instead. CoreData: warning: Unable to load class named 'ContactsPersistence.CNEWSMapping' for entity 'Mapping'. Class not found, using default NSManagedObject instead. 2023-01-06 14:17:54.771035+0000 [ABCDContact] An ABCDRecord is being saved without having a container assignment. Assigning the contact to <CNCDContainer 0x600000a89980 ab>. Please remember to assign contacts to containers to avoid recurring container lookup and contact re-validation costs. What am I missing? What am I doing wrong? Thanks for any help you can offer!
0
0
837
Jan ’23
Help! Get a contact and store it in CoreData
overview of the problem I'm making an app with SwiftUI. We even implemented fetching contacts using CNContactStore. The goal is to get the contacts and store them separately in CoreData. This is because you need to assign and manage attributes that are not in the default contact. class ContactStore: ObservableObject {   @Environment(\.managedObjectContext) private var viewContext   @Published var error: Error? = nil   @Published var results: [CNContact] = []       func fetch() {     do {       let store = CNContactStore()       let keysToFetch = [CNContactGivenNameKey as CNKeyDescriptor,                 CNContactMiddleNameKey as CNKeyDescriptor,                 CNContactFamilyNameKey as CNKeyDescriptor,                 CNContactImageDataAvailableKey as CNKeyDescriptor,                 CNContactPhoneNumbersKey as CNKeyDescriptor,                 CNContactImageDataKey as CNKeyDescriptor]       os_log("Fetching contacts: now")       let containerId = store.defaultContainerIdentifier()       let predicate = CNContact.predicateForContactsInContainer(withIdentifier: containerId)       let contacts = try store.unifiedContacts(matching: predicate, keysToFetch: keysToFetch)       os_log("Fetching contacts: succesfull with count = %d", contacts.count)       self.results = contacts       print(results)     } catch let error {       print("error occured! : \(error.localizedDescription)")     }   } } problem Is there a way to store the contact information in the array 'results' as CoreData? The attributes set in CoreData are 'name', 'phone', and 'company'.
1
0
1.2k
Dec ’22
Modify contacts.app to print christmas labels - resign required....
Hi! I'm not a developer but hope someone can help me... I've regularly updated the standard contacts app to include a file called ABRelatedNamesConfig.plist in Resources. This file just has the contents below. By including this, it meant that the Contacts.app was able to print address labels including spouse and children such as: "Mr John and Jane Smith and Kenny, Jill and Bertie" which was great for Christmas cards.... This feature was standard but got removed in MacOS a few versions ago but the code still worked when you put the file back into a Contacts.app copy (renamed). HOWEVER with Ventura it won't play ball now because the app needs resigning. Can anyone tell me how I can sign the app again (I guess as myself rather than Apple?). Thanks if you can help... I've tried code sign and changing terminal to be able to do app management and/or full disk access but that didn't seem to work and I don't really know what I'm doing... I know Google is my friend... but... <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>ca</key> <true/> <key>gb</key> <true/> <key>us</key> <true/> <key>fr</key> <true/> <key>no</key> <true/> <key>au</key> <true/> <key>de</key> <true/> <key>ch</key> <true/> </dict> </plist>
0
0
743
Dec ’22
CKError 429 from CloudKit, using CKDiscoverAllUserIdentitiesOperation
I am working with the CKDiscoverAllUserIdentitiesOperation. I would like to fetch all users, however, CloudKit returns the following error: <CKError 0x6000009ce040: "Request Rate Limited" (7/2058); "Operation throttled by previous server http 429 reply. Retry after 6432.8 seconds. (Other operations may be allowed.)"; Retry after 6432.8 seconds> Here's my code: var identities = [CKUserIdentity]() let operation = CKDiscoverAllUserIdentitiesOperation() operation.userIdentityDiscoveredBlock = { userIdentity in identities.append(userIdentity) } operation.discoverAllUserIdentitiesCompletionBlock = { error in if let error = error { fatalError(error.localizedDescription) } else { completion(identities) } } operation.qualityOfService = .userInitiated CKContainer.default().add(operation) App adds that operation in the viewDidAppear method . Also I have requested to the application permission for user discoverability (accodring to the Apple's documentation: https://developer.apple.com/documentation/cloudkit/ckdiscoveralluseridentitiesoperato)
1
0
1.2k
Dec ’22
What size image to programmatically add to a contact such that it'll appear on the call screen nicely?
I want to programmatically create a contact with an image with the result that when the iPhone receives a call from the number associated with that contact its image will appear on the incoming call screen (occupying the full screen, not the little tiny icon variation). But I'm having a hell of a job trying to figure out what dimensions should be used for the image to add to the contact. If on the iPhone I take a screenshot and add that manually to a contact then make a call, then the call screen more or less displays the entire screenshot almost the same as the actual desktop. The call screen appears to be slightly magnifying the image. So whatever size the screenshot is should be close enough for the contact image. I've got an iPhone 14 pro and its UIScreen.main.bounds is 932 by 430. If I export an iPhone screenshot to a Mac, I can see its image size is 2796 by 1290, which is exactly 3 times the bounds size. So I created an image of size 2796 by 1290 and programmatically added it to a contact (using CNMutableContact.imageData = myUIImage.pngData(). But when a call arrives the image that gets displayed on the call screen is way way way out of whack and alignment. Same too if I add am image of size 932 by 430 (i.e. without the 3 times factor). I've done lots of experiments but I just can't figure out what size image I should add to the contact. Does anybody happen to know? (I exported the contact where I manually added the screenshot image as a .vcf to see what image size they use, but it doesn't export the full image that's actually displayed during a call screen, it just exports a truncation of the full image which is a square of 1200 by 1200.)
0
0
878
Dec ’22
Adding or using Note Field Access Entitlement
Hello, Ive ben having an issue with one of my Apps since Ventura came out. The app won't create a new contact It fails giving a few different warnings but no real error. I have tried it unto Ventura 13.0.1 (22A400) The error is 2022-12-03 09:33:54.543143+1000 **** [1941:15105] [api] Attempt to write notes by an unentitled app 2022-12-03 09:33:54.580714+1000 **** [1941:15105] [plugin] CDX_AB_GetGroupCollectionPath: nil group 2022-12-03 09:33:54.580765+1000  **** [1941:15105] [plugin] CDX_AB_GetGroupCollectionPath: nil group 2022-12-03 09:33:54.581969+1000 **** [1941:15105] [ABCDContact] An ABCDRecord is being saved without having a container assignment. Assigning the contact to <CNCDContainer 0x6000013c92c0 ab>. Please remember to assign contacts to containers to avoid recurring container lookup and contact re-validation costs. . When I follow the instructions on this page https://developer.apple.com/documentation/contacts to create a new contact It fails on Ventura to create a new contact and I don't know why. So I submitted a feedback Assistant request (FB11721907) But I also went ahead and got Notes field access as that was one of the warnings. That got approved, Now I would like help adding it in my project. I logged into the Developer Portal and in Identifiers, located my app and went to Additional Capabilities ticked the Box marked Contacts Notes Field Access. Then instructions in the email say 'Once you’ve finished generating the profile, you can use it in Xcode like any other manually-generated profile.' Im not sure what this means. I tried to add 'com.apple.developer.contacts.notes' Boolean, YES, to the entitlement file as described in https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_contacts_notes but the app doesn't launch when it's added. And if I put it into the info.plist file it does nothing. Also im not sure how to add the purpose string.
1
0
2.1k
Dec ’22
Has anyone figured out how to create a CNContainer in an iOS device?
Apple Documentation says that there is only one CNContainer in an iOS device of type local. Creating a container of type exchange requires using Exchange, and creating a container of type cardDAV requires a server also. Is there any way to create a container of type unassigned? I would need to do this programmatically in Swift to use in my iOS app. This question and the posts it mentions give no answer.
2
0
2.0k
Dec ’22
CNContactPickerViewController long Press on the contact name behaviour is different from iOS 15 and iOS 16
in iOS 15 in CNContactPickerViewController after long press on the contact and then selecting the contact it's navigating to the the specific contact details Please check the reference video: https://www.dropbox.com/s/6z5l4kz37rapbus/iOS_15_Behavior.MP4?dl=0 in iOS 16 in CNContactPickerViewController after long press on the contact and then selecting the contact it simply closing the picker Please check the reference video: https://www.dropbox.com/s/qu861la3dikxugq/iOS_16_Behavior.MP4?dl=0 Why this change ? Is it possible same behaviour in iOS 16 also ? is there any supporting documentation about this ?
0
0
828
Nov ’22
EXC_BAD_ACCESS crash when enumerating contacts
Hi, I'm encountering a crash when attempting to enumerate contacts using a block-based enumeration method. The crash log shows an EXC_BAD_ACCESS error. I suspect the crash may be related to a memory management issue, but I'm having trouble pinpointing the exact cause. The crash have on Crashlytics but can not reproduce. Has anyone else encountered this issue or have any suggestions for troubleshooting this type of crash? Any help would be greatly appreciated. Thank you! Crash log: EXC_BAD_ACCESS (KERN_INVALID_ADDRESS) 0 libobjc.A.dylib 0x307c objc_retain_x8 + 16 1 Contacts 0x2c318 __52-[CNXPCDataMapper contactObservableForFetchRequest:]_block_invoke + 260 2 ContactsFoundation 0xc344 __26-[CNObservable doOnError:]_block_invoke + 320 3 ContactsFoundation 0xc728 __31-[CNObservable doOnCompletion:]_block_invoke + 320 4 ContactsFoundation 0xc728 __31-[CNObservable doOnCompletion:]_block_invoke + 320 5 ContactsFoundation 0xc344 __26-[CNObservable doOnError:]_block_invoke + 320 6 ContactsFoundation 0x8048 __27-[CNObservable doOnCancel:]_block_invoke + 252 7 ContactsFoundation 0xbb88 -[CNObservable enumerateObjectsUsingBlock:] + 404 8 Contacts 0xb48f8 __91-[CNDataMapperContactStore enumerateContactsAndMatchInfoWithFetchRequest:error:usingBlock:]_block_invoke.61 + 552 9 Contacts 0x315c4 __38-[_CNContactsLogger fetchingContacts:]_block_invoke_2 + 44 10 libsystem_trace.dylib 0xa108 os_activity_apply_f + 88 11 Contacts 0x221fc -[_CNContactsLogger fetchingContacts:] + 248 12 Contacts 0x2149c -[CNDataMapperContactStore enumerateContactsAndMatchInfoWithFetchRequest:error:usingBlock:] + 528 13 Contacts 0x21174 -[CNContactStore pool_enumerateContactsWithFetchRequest:error:usingBlock:] + 268 14 Contacts 0x22ab0 -[CNContactStore enumerateContactsWithFetchRequest:error:usingBlock:] + 492 Source code: @synchronized (contactStore) { @try { [contactStore enumerateContactsWithFetchRequest:listKeyToFetch error:&amp;error usingBlock:^(CNContact* cnContact, BOOL* stop) { Contact *contact = [Contact newWithCNContact:cnContact]; if (filter(contact)) { [contacts addObject:contact]; } }]; } }
Replies
3
Boosts
0
Views
1.3k
Activity
Mar ’23
NSCocoaErrorDomain Code=134092 When Updating ContactsError, and Error "Attempt to read notes by an unentitled app" while I am not request for notes
Hi, I'm writing a command line program with Swift Package Manager that uses Contacts API to automatically add phonetic names for the contacts. However, I found I was unable to do so for contacts that has notes. First, when I was trying to enumerate the contacts, there is a strange error output: 2023-01-22 18:58:36.085525+0800 PhoneticNames[18591:98356] [core] Attempted to register account monitor for types client is not authorized to access: {( "com.apple.account.CardDAV", "com.apple.account.Exchange", "com.apple.account.LDAP" )} 2023-01-22 18:58:36.085580+0800 PhoneticNames[18591:98356] [accounts] CNAccountCollectionUpdateWatcher 0x6000003ccc40: Store registration failed: Error Domain=com.apple.accounts Code=7 "(null)" 2023-01-22 18:58:36.085606+0800 PhoneticNames[18591:98356] [accounts] CNAccountCollectionUpdateWatcher 0x6000003ccc40: Update event received, but store registration failed. This event will be handled, but the behavior is undefined. 2023-01-22 18:58:36.136236+0800 PhoneticNames[18591:98344] [api] Attempt to read notes by an unentitled app According to this document, I need to add the notes entitlement only if I was requesting the note field with CNContactNoteKey. However, I was not requesting it and I still get that "Attempt to read notes by an unentitled app" error. Here is my code for enumerating the contacts: let keys: [CNKeyDescriptor] = [CNContactFormatter.descriptorForRequiredKeys(for: .fullName), CNContactFormatter.descriptorForRequiredKeys(for: .phoneticFullName)] let fetchRequest = CNContactFetchRequest(keysToFetch: keys as [CNKeyDescriptor]) fetchRequest.mutableObjects = true do { try store.enumerateContacts(with: fetchRequest) { (contact, stop) in contacts.append(contact.mutableCopy() as! CNMutableContact) } } catch { print("unable to list contacts. \(error)") } And this is how I update the contacts later: let saveRequest = CNSaveRequest() contact.phoneticFamilyName = phoneticFamilyName contact.phoneticMiddleName = phoneticMiddleName contact.phoneticGivenName = phoneticGivenName saveRequest.update(contact) do { try store.execute(saveRequest) } catch { print("Fail to execute store request: \(error)") } This code works as expected for contacts without the note field. But for contact with a non-empty note field, the saveRequest fails and outputs the following error: 2023-01-22 18:58:36.197026+0800 PhoneticNames[18591:98344] [error] error: Unhandled error occurred during faulting: Error Domain=NSCocoaErrorDomain Code=134092 "(null)" ({ }) CoreData: error: Unhandled error occurred during faulting: Error Domain=NSCocoaErrorDomain Code=134092 "(null)" ({ }) 2023-01-22 18:58:36.201308+0800 PhoneticNames[18591:98344] [plugin] CDX_AB_GetGroupCollectionPath: nil group 2023-01-22 18:58:36.201353+0800 PhoneticNames[18591:98344] [plugin] CDX_AB_GetGroupCollectionPath: nil group In debugging mode inside Xcode, the contact will still be updated with phoetic names. But if I execute the compiled release binary in terminal, the output will be: CoreData: error: Unhandled error occurred during faulting: Error Domain=NSCocoaErrorDomain Code=134092 "(null)" ({ }) Fail to execute store request: Error Domain=NSCocoaErrorDomain Code=134092 "(null)" UserInfo={NSUnderlyingException=Unhandled error (NSCocoaErrorDomain, 134092) occurred during faulting and was thrown: Error Domain=NSCocoaErrorDomain Code=134092 "(null)", NSUnderlyingError=0x600002ee05d0 {Error Domain=NSCocoaErrorDomain Code=134092 "(null)"}} The contact will not be updated in this case. I looked for all the documents but couldn't find anything about NSCocoaErrorDomain Code 134092. Can you please give me some clues about the aforementioned behaviors?
Replies
2
Boosts
2
Views
2.2k
Activity
Mar ’23
Issue with contacts synchronization
Hi, we are building an app to sync contacts for event organization. The app can sync between 100 to 1000 contacts to the Contacts app of iOS. We can't manage the device because the user can bring their own device. We are currently facing an issue with thirdparty application like Whatsapp/Signal/Telegram because they sync the contacts from and to the phone. When the sync is enabled in one of this app we can't delete all the contacts at the end of the event because they are synced back to the Contacts app. When we update the contact it also get messed up by those apps. Do you know an workaround to prevent this scenario? Is it possible to prevent thos apps to sync a contact?
Replies
0
Boosts
0
Views
556
Activity
Feb ’23
escaping and non-escaping closure error in contact request
I get the error "Escaping closure captures non-escaping parameter 'completionHandler'" for the following code. I tried to add @escaping, but I honestly don't really get where and how. Did anybody had a similar problem and could help. Thank You!                 if access {                     completionHandler(access)                 }                 else {                     if authorizationStatus == CNAuthorizationStatus.denied {                         DispatchQueue.main.async {                             let message = "\(accessError!.localizedDescription)\n\n\(NSLocalizedString("Bitte ändere dies in den Gerät Einstellungen.", comment: ""))"                             self.showMessage(message: message, controll: controll)                         }                     }                 }             })
Replies
2
Boosts
0
Views
863
Activity
Feb ’23
Drag and Drop Contacts not working in Ventura
This code was working fine in Monterey but since upgrading to Ventura it no longer works: let contactsUTTypes = [UTType.vCard, UTType.contact] func performDrop(info: DropInfo) -> Bool {     print (info)     let items = info.itemProviders(for: contactsUTTypes)     print (items)     for item in items     {         item.loadDataRepresentation(forTypeIdentifier: UTType.vCard.identifier, completionHandler: { (data, error) in             if let data = data,                let contact = try? CNContactVCardSerialization.contacts(with: data).first             {                 print("Contact: \(contact.givenName)")             }         })     }     return true } let items = info.itemProviders(for: uttypes) always returns zero items Has this been broken in Ventura or do I need to do this differently now?
Replies
2
Boosts
0
Views
969
Activity
Feb ’23
App contacts
There are 2 things that I do not quite understand about the apple operating system and that every year is updated to a new version, supposedly with improvements, and that these two issues that are day to day and that all people use at all times. One of them is the contacts app, can someone tell me why it has not been developed the possibility of being able to sort my contacts by several fields other than first and last name, for example COMPANY. Everyone can have several of the same names, for example, juan. But from different companies, and this information does not appear neither in the list of contacts nor as a possibility to sort. IT'S UNBELIEVABLE! So many cutting edge updates and improvements and this is still the same since the first day almost 20 years ago. thanks
Replies
4
Boosts
0
Views
1.1k
Activity
Feb ’23
Rate Limit Exceeded for CardDAV connections
We've been supporting iCloud CardDAV contacting syncing for over 8 years. Never once had a problem before, but past week or so we've had numerous reports from users where they're seeing "Rate Limit Exceeded" errors coming from iCloud. What are these limits? How can developers request for an increase (where users genuinely import hundreds of new contacts daily)? Google contacts, for instance, allows developers to apply for an increase. There seems to be nothing in relation to this in the documentation. We have no clue what these limits even are.
Replies
3
Boosts
7
Views
1.6k
Activity
Feb ’23
What size image should be added to a contact such that it appears in full screen mode on the incoming call screen?
I'm programmatically adding a contact with an image with the intention the image should display in full screen size when a caller matching the number of the contact calls (as opposed to the image appearing as a tiny round icon next to the caller name). I'm creating an image of the same size and scale factor as the iPhone, and so far its working out ok - I have about 15 different phones, of various dimensions and scale factors, ranging from an old iPhone mini up to the most recent iPhone Pro Max, and on all of these it works as intended. But there's an exception, an iPhone 12 Pro (which has dimensions 390 * 844 and scale factor 3), on this phone when there is a call the contact image appears as a tiny icon. Why. Why is this phone different? How can I know what size image should be added to a contact to appear at full size in the call screen when every phone has different dimensions and they are not behaving the same? Additional question - the iPhone applies some cropping and expansion to whatever image gets added, is it possible to know what's being done to the image in order to make it display perfectly? (i.e. if the image contains some text, the fact the OS crops away some of the edge of the image, then expands what's left to fill the screen dimensions results in some pixelation)
Replies
0
Boosts
0
Views
647
Activity
Feb ’23
iCloud CardDAV API - FN property (vCard) sometimes empty
The iCloud CardDAV interface occasionally returns vCards with empty FN value (https://www.rfc-editor.org/rfc/rfc6350#section-6.2.1). The behavior seems to occur only since a few months (noticed by customer reports of our CardDAV client). here is an example vCard: BEGIN:VCARD VERSION:3.0 FN: N:LastName;Firstname;;; UID:.vcf PRODID:-//Apple Inc.//iCloud Web Address Book 2304B11//EN REV:2023-01-03T17:21:11Z ORG:; TEL;TYPE=HOME:<phone_nr> END:VCARD After a resynchronization of the contact data, the vCards with empty "FN" values seem to vary (other contacts are affected by that issue than before). Everything seems to be fine on the iCloud website or in the iPhone contacts app.
Replies
0
Boosts
0
Views
1.2k
Activity
Feb ’23
Adding Contact to Device Contacts app crashing in macOS ventura
We are using CNSaveRequest in CNContactStore to add contacts to system device contacts. But when calling execute method the app crashing in internal libraries.The code was working fine until macOS Monetery, In macOS Ventura beta we are facing this issue. Sample Code: let store = CNContactStore() store.requestAccess(for: .contacts, completionHandler: { isSuccess,error in guard isSuccess else { return } let contact = CNMutableContact() contact.familyName = "Hello" contact.givenName = "Contact" let request = CNSaveRequest() request.add(contact, toContainerWithIdentifier: nil) do { try store.execute(request) } catch { print(error) } }) Crash:
Replies
5
Boosts
2
Views
2.7k
Activity
Feb ’23
How should you programatically add a contact so it remains only on the device and isn't synched to iCloud?
I want to programmatically add a contact, preferably within its own group, such that it remains only on the (iPhone) device local copy of contacts and doesn't get synched elsewhere. However if I programmatically create a group then the group itself appears in iCloud, so presumably contacts within it will to. What sort of arrangement of containers/groups/contacts etc. should I create to achieve this?
Replies
0
Boosts
0
Views
1.3k
Activity
Jan ’23
Parsing preferred phonenumbers with CNPhoneNumber from vcf-file
I try to parse a vcf-file. I use CNContact for this. That works quite well, but with the phonenumbers i have a problem. With CNLabeledValue&lt;CNPhoneNumber*&gt;* I get the label (e. g. "home") and the phonenumber in the value. Excerpt from the vCard: TEL;TYPE=home:1234567890 But if the number is tagged with a "pref" i can't get this tag for the phonenumber. Excerpt from the vCard: TEL;TYPE=home,pref:0987654321 Is there anyway to find out, which numbers are the preferred numbers? I use following code: for (CNLabeledValue&lt;CNPhoneNumber*&gt;* number in cnContact.phoneNumbers) { NSString *label = number.label; NSString *number = ((CNPhoneNumber*)number).stringValue; //Do some work with label and number }
Replies
0
Boosts
0
Views
743
Activity
Jan ’23
How do I create & update CNContacts on macOS?
My attempts at creating a new CNContact fail with error message EXC_BAD_ACCESS (code=1, address=... at runtime Attempting to update an existing record appears to change the CNContact record, but the change is not visible in Apple's Contacts app. Code: Code I have so far: var status: Bool = false store.requestAccess(for: CNEntityType.contacts) { hasPermission, error in if error != nil { print(error!) } status = hasPermission } let newContact = CNMutableContact() newContact.givenName = "NBED-given" newContact.familyName = "NBED-family" let saveRequest = CNSaveRequest() saveRequest.add(newContact, toContainerWithIdentifier: store.defaultContainerIdentifier()) do { try store.execute(saveRequest) } catch { print("Error:\t\(error)") } ... and ... guard let contact = contactToAmend.mutableCopy() as? CNMutableContact else { return } contact.givenName = "NEW NAME" let saveRequest = CNSaveRequest() saveRequest.add(contact, toContainerWithIdentifier: store.defaultContainerIdentifier()) do { try store.execute(saveRequest) print("Stored ok") } catch { print("Error:\t\(error)") } Looking up this Contact in the Contacts app, I can search for it with the new given name ("NEW NAME"), but the record is then shown with its old (unchanged) name. It's also worth adding that I am seeing a number of messages / warnings in XCode during runtime: 2023-01-06 14:17:45.628226+0000 [api] Attempt to read notes by an unentitled app 2023-01-06 14:17:54.164223+0000 Metal API Validation Enabled 2023-01-06 14:17:54.436906+0000 [api] Attempt to write notes by an unentitled app CoreData: warning: Unable to load class named 'ContactsPersistence.CNEWSContactFolder' for entity 'ContactFolder'. Class not found, using default NSManagedObject instead. CoreData: warning: Unable to load class named 'ContactsPersistence.CNEWSMapping' for entity 'Mapping'. Class not found, using default NSManagedObject instead. 2023-01-06 14:17:54.771035+0000 [ABCDContact] An ABCDRecord is being saved without having a container assignment. Assigning the contact to <CNCDContainer 0x600000a89980 ab>. Please remember to assign contacts to containers to avoid recurring container lookup and contact re-validation costs. What am I missing? What am I doing wrong? Thanks for any help you can offer!
Replies
0
Boosts
0
Views
837
Activity
Jan ’23
Help! Get a contact and store it in CoreData
overview of the problem I'm making an app with SwiftUI. We even implemented fetching contacts using CNContactStore. The goal is to get the contacts and store them separately in CoreData. This is because you need to assign and manage attributes that are not in the default contact. class ContactStore: ObservableObject {   @Environment(\.managedObjectContext) private var viewContext   @Published var error: Error? = nil   @Published var results: [CNContact] = []       func fetch() {     do {       let store = CNContactStore()       let keysToFetch = [CNContactGivenNameKey as CNKeyDescriptor,                 CNContactMiddleNameKey as CNKeyDescriptor,                 CNContactFamilyNameKey as CNKeyDescriptor,                 CNContactImageDataAvailableKey as CNKeyDescriptor,                 CNContactPhoneNumbersKey as CNKeyDescriptor,                 CNContactImageDataKey as CNKeyDescriptor]       os_log("Fetching contacts: now")       let containerId = store.defaultContainerIdentifier()       let predicate = CNContact.predicateForContactsInContainer(withIdentifier: containerId)       let contacts = try store.unifiedContacts(matching: predicate, keysToFetch: keysToFetch)       os_log("Fetching contacts: succesfull with count = %d", contacts.count)       self.results = contacts       print(results)     } catch let error {       print("error occured! : \(error.localizedDescription)")     }   } } problem Is there a way to store the contact information in the array 'results' as CoreData? The attributes set in CoreData are 'name', 'phone', and 'company'.
Replies
1
Boosts
0
Views
1.2k
Activity
Dec ’22
Modify contacts.app to print christmas labels - resign required....
Hi! I'm not a developer but hope someone can help me... I've regularly updated the standard contacts app to include a file called ABRelatedNamesConfig.plist in Resources. This file just has the contents below. By including this, it meant that the Contacts.app was able to print address labels including spouse and children such as: "Mr John and Jane Smith and Kenny, Jill and Bertie" which was great for Christmas cards.... This feature was standard but got removed in MacOS a few versions ago but the code still worked when you put the file back into a Contacts.app copy (renamed). HOWEVER with Ventura it won't play ball now because the app needs resigning. Can anyone tell me how I can sign the app again (I guess as myself rather than Apple?). Thanks if you can help... I've tried code sign and changing terminal to be able to do app management and/or full disk access but that didn't seem to work and I don't really know what I'm doing... I know Google is my friend... but... <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>ca</key> <true/> <key>gb</key> <true/> <key>us</key> <true/> <key>fr</key> <true/> <key>no</key> <true/> <key>au</key> <true/> <key>de</key> <true/> <key>ch</key> <true/> </dict> </plist>
Replies
0
Boosts
0
Views
743
Activity
Dec ’22
CKError 429 from CloudKit, using CKDiscoverAllUserIdentitiesOperation
I am working with the CKDiscoverAllUserIdentitiesOperation. I would like to fetch all users, however, CloudKit returns the following error: <CKError 0x6000009ce040: "Request Rate Limited" (7/2058); "Operation throttled by previous server http 429 reply. Retry after 6432.8 seconds. (Other operations may be allowed.)"; Retry after 6432.8 seconds> Here's my code: var identities = [CKUserIdentity]() let operation = CKDiscoverAllUserIdentitiesOperation() operation.userIdentityDiscoveredBlock = { userIdentity in identities.append(userIdentity) } operation.discoverAllUserIdentitiesCompletionBlock = { error in if let error = error { fatalError(error.localizedDescription) } else { completion(identities) } } operation.qualityOfService = .userInitiated CKContainer.default().add(operation) App adds that operation in the viewDidAppear method . Also I have requested to the application permission for user discoverability (accodring to the Apple's documentation: https://developer.apple.com/documentation/cloudkit/ckdiscoveralluseridentitiesoperato)
Replies
1
Boosts
0
Views
1.2k
Activity
Dec ’22
What size image to programmatically add to a contact such that it'll appear on the call screen nicely?
I want to programmatically create a contact with an image with the result that when the iPhone receives a call from the number associated with that contact its image will appear on the incoming call screen (occupying the full screen, not the little tiny icon variation). But I'm having a hell of a job trying to figure out what dimensions should be used for the image to add to the contact. If on the iPhone I take a screenshot and add that manually to a contact then make a call, then the call screen more or less displays the entire screenshot almost the same as the actual desktop. The call screen appears to be slightly magnifying the image. So whatever size the screenshot is should be close enough for the contact image. I've got an iPhone 14 pro and its UIScreen.main.bounds is 932 by 430. If I export an iPhone screenshot to a Mac, I can see its image size is 2796 by 1290, which is exactly 3 times the bounds size. So I created an image of size 2796 by 1290 and programmatically added it to a contact (using CNMutableContact.imageData = myUIImage.pngData(). But when a call arrives the image that gets displayed on the call screen is way way way out of whack and alignment. Same too if I add am image of size 932 by 430 (i.e. without the 3 times factor). I've done lots of experiments but I just can't figure out what size image I should add to the contact. Does anybody happen to know? (I exported the contact where I manually added the screenshot image as a .vcf to see what image size they use, but it doesn't export the full image that's actually displayed during a call screen, it just exports a truncation of the full image which is a square of 1200 by 1200.)
Replies
0
Boosts
0
Views
878
Activity
Dec ’22
Adding or using Note Field Access Entitlement
Hello, Ive ben having an issue with one of my Apps since Ventura came out. The app won't create a new contact It fails giving a few different warnings but no real error. I have tried it unto Ventura 13.0.1 (22A400) The error is 2022-12-03 09:33:54.543143+1000 **** [1941:15105] [api] Attempt to write notes by an unentitled app 2022-12-03 09:33:54.580714+1000 **** [1941:15105] [plugin] CDX_AB_GetGroupCollectionPath: nil group 2022-12-03 09:33:54.580765+1000  **** [1941:15105] [plugin] CDX_AB_GetGroupCollectionPath: nil group 2022-12-03 09:33:54.581969+1000 **** [1941:15105] [ABCDContact] An ABCDRecord is being saved without having a container assignment. Assigning the contact to <CNCDContainer 0x6000013c92c0 ab>. Please remember to assign contacts to containers to avoid recurring container lookup and contact re-validation costs. . When I follow the instructions on this page https://developer.apple.com/documentation/contacts to create a new contact It fails on Ventura to create a new contact and I don't know why. So I submitted a feedback Assistant request (FB11721907) But I also went ahead and got Notes field access as that was one of the warnings. That got approved, Now I would like help adding it in my project. I logged into the Developer Portal and in Identifiers, located my app and went to Additional Capabilities ticked the Box marked Contacts Notes Field Access. Then instructions in the email say 'Once you’ve finished generating the profile, you can use it in Xcode like any other manually-generated profile.' Im not sure what this means. I tried to add 'com.apple.developer.contacts.notes' Boolean, YES, to the entitlement file as described in https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_contacts_notes but the app doesn't launch when it's added. And if I put it into the info.plist file it does nothing. Also im not sure how to add the purpose string.
Replies
1
Boosts
0
Views
2.1k
Activity
Dec ’22
Has anyone figured out how to create a CNContainer in an iOS device?
Apple Documentation says that there is only one CNContainer in an iOS device of type local. Creating a container of type exchange requires using Exchange, and creating a container of type cardDAV requires a server also. Is there any way to create a container of type unassigned? I would need to do this programmatically in Swift to use in my iOS app. This question and the posts it mentions give no answer.
Replies
2
Boosts
0
Views
2.0k
Activity
Dec ’22
CNContactPickerViewController long Press on the contact name behaviour is different from iOS 15 and iOS 16
in iOS 15 in CNContactPickerViewController after long press on the contact and then selecting the contact it's navigating to the the specific contact details Please check the reference video: https://www.dropbox.com/s/6z5l4kz37rapbus/iOS_15_Behavior.MP4?dl=0 in iOS 16 in CNContactPickerViewController after long press on the contact and then selecting the contact it simply closing the picker Please check the reference video: https://www.dropbox.com/s/qu861la3dikxugq/iOS_16_Behavior.MP4?dl=0 Why this change ? Is it possible same behaviour in iOS 16 also ? is there any supporting documentation about this ?
Replies
0
Boosts
0
Views
828
Activity
Nov ’22