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

CNContact identifiers
Hi,I saw the WWDC talk on the new Contacts framework, and I had a couple of questions about the identifier property:When users upgrade from iOS8 to iOS9, will their old AddressBook recordIDs still work if we are using the AddressBook framework in the app (i.e. haven't upgraded to using Contacts framework)?Are the new CNContact identifiers consistent across iOS and Mac devices? i.e. if we have the identifier on one device, we can lookup the contact on another device with the same identifier?Can these identifiers change in the lifetime of that contact? This was a problem with AddressBook recordIDs ... if you removed the account and then synced it back again, all the contacts would get a different identifier. Same with restoring the device. Will the CNGroup and CNContainer identifiers also be consistent across devices?Hope someone in the Apple Contacts frameworks team can answer. Thanks.
6
0
4.7k
Jul ’23
Unable to retrieve contacts from a linked Exchange account
On my iPhone, in Settings, I've added my company Exchange account. Consequently, within the Contacts app, 4 new lists appear - the bottom as shown in the attached image. There's a few thousand contacts in the Company Exchange account, so why are the count values showing as 0? If I click on the Global Address list and search, it can succfully find whatever I search for. I want to programatically retrieve the contacts within the Exchange account, in addition to those stored locally or within iCloud, however if I execute the following code, for the container of type exchange, the count of results of the call to unifiedContacts() is 0. How can I programatically get the Exchange contacts? If the call to unifiedContacts() is resulting in 0 because the count for the lists when viewing the Contacts app is 0, then how to make it not 0 in the Contacts app (but if that were the case, how come manually searching for a contact is successful?) let keysToFetch = [ CNContactFormatter.descriptorForRequiredKeys(for: .fullName), CNContactPhoneNumbersKey, CNContactEmailAddressesKey, CNContactThumbnailImageDataKey] as [Any] var allContainers: [CNContainer] = [] do { allContainers = try CNContactStore().containers(matching: nil) } catch { print("Error fetching containers") } var results: [CNContact] = [] for container in allContainers { let type = container.type let identifier = container.identifier let fetchPredicate = CNContact.predicateForContactsInContainer(withIdentifier: container.identifier) do { let containerResults = try CNContactStore().unifiedContacts(matching: fetchPredicate, keysToFetch: keysToFetch as! [CNKeyDescriptor]) let count = containerResults.count results.append(contentsOf: containerResults) } catch { print("Error fetching containers") } }
0
0
693
Jul ’23
Apple pay shipping details and contact info
Hi, we are using following setting in our web app to capture customer contact/shipping details: we have selected "detailed request" from "Apple pay payment request" It leads to parsing of following data: However, we do not need the **postal address, ** just email and contact is enough. The problem is in many cases users have not added a shipping address to their apple account, which leads to this screen in case they try to pay: Is it possible to just ask users for "contact number" and "email address" and EXCLUDE asking shipping address which they might have not added, so the payment goes through even if the user has not updated the "address".
0
0
952
Jul ’23
Playground execution failed: error: Execution was interrupted, reason: shared-library-event.
Why did I get an error in playground in debug window for this code? print("// MARK: - Start execable code here...") do { let store = CNContactStore() if try await store.requestAccess(for: .contacts) { // Do something with Contacts. let phoneNumber = CNPhoneNumber(stringValue: "903-276-1046") let predicateForContactsMatchingPhoneNumber = CNContact.predicateForContacts(matching: phoneNumber) let contactFetchRequest = CNContactFetchRequest(keysToFetch: thoroughKeysToCompare) contactFetchRequest.predicate = predicateForContactsMatchingPhoneNumber contactFetchRequest.unifyResults = true var contactOfMe: CNContact! = nil try! store.enumerateContacts(with: contactFetchRequest) { contact, stop in contactOfMe = contact stop.pointee = true } let contact = Contact(cnContact: contactOfMe) for property in contact.enumerated() { print("- \(property)") } } else { // Handle if Contacts access is denied. fatalError() } } catch { // Handle any error. print("error requesting access: \(error.localizedDescription)") } Debug window: // MARK: - Start execable code here... Playground execution failed: error: Execution was interrupted, reason: shared-library-event. The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation. * thread #1, queue = 'com.apple.main-thread' frame #0: 0x00007ff80002f931 libobjc.A.dylib`_mapStrHash(_NXMapTable*, void const*) + 73 frame #1: 0x00007ff80002fc7f libobjc.A.dylib`_NXMapMember(_NXMapTable*, void const*, void**) + 35 frame #2: 0x00007ff80003b7ae libobjc.A.dylib`getProtocol(char const*) + 41 frame #3: 0x00007ff8000428e6 libobjc.A.dylib`class_conformsToProtocol + 337 frame #4: 0x00007ff80004ab4e libobjc.A.dylib`-[NSObject conformsToProtocol:] + 47 frame #5: 0x0000000109c27951 UIKitCore`_UIFocusItemContainerIsScrollableContainer + 74 frame #6: 0x0000000109c28e38 UIKitCore`-[_UIFocusEnvironmentContainerTuple initWithOwningEnvironment:itemContainer:] + 194 frame #7: 0x0000000109c28fed UIKitCore`+[_UIFocusEnvironmentContainerTuple tupleWithOwningEnvironment:itemContainer:] + 70 frame #8: 0x0000000109c4f41e UIKitCore`_UIFocusRegionContainerFromEnvironmentAndContainer + 44 frame #9: 0x0000000109c27ed3 UIKitCore`_UIFocusItemContainerAddChildItemsInContextWithArguments + 1162 frame #10: 0x000000010a99c439 UIKitCore`-[UIView _searchForFocusRegionsInContext:] + 962 frame #11: 0x0000000109c6b37f UIKitCore`-[_UIFocusMapSnapshot addRegionsInContainer:] + 4583 frame #12: 0x0000000109c69740 UIKitCore`-[_UIFocusMapSnapshot _capture] + 456 frame #13: 0x0000000109c67fc5 UIKitCore`-[_UIFocusMapSnapshot _initWithSnapshotter:mapArea:searchArea:] + 628 frame #14: 0x0000000109c6cce2 UIKitCore`-[_UIFocusMapSnapshotter captureSnapshot] + 227 frame #15: 0x0000000109c5f450 UIKitCore`-[_UIFocusMap _inferredDefaultFocusItemInEnvironment:] + 147 frame #16: 0x0000000109c2b1cf UIKitCore`-[_UIFocusEnvironmentPreferenceEnumerationContext _inferPreferencesForEnvironment:] + 157 frame #17: 0x0000000109c2abbc UIKitCore`-[_UIFocusEnvironmentPreferenceEnumerationContext _resolvePreferredFocusEnvironments] + 118 frame #18: 0x0000000109c2ab12 UIKitCore`-[_UIFocusEnvironmentPreferenceEnumerationContext prefersNothingFocused] + 31 frame #19: 0x0000000109c2beeb UIKitCore`_enumeratePreferredFocusEnvironments + 198 frame #20: 0x0000000109c2c061 UIKitCore`_enumeratePreferredFocusEnvironments + 572 frame #21: 0x0000000109c2c061 UIKitCore`_enumeratePreferredFocusEnvironments + 572 frame #22: 0x0000000109c2c061 UIKitCore`_enumeratePreferredFocusEnvironments + 572 frame #23: 0x0000000109c2bd11 UIKitCore`-[_UIFocusEnvironmentPreferenceEnumerator enumeratePreferencesForEnvironment:usingBlock:] + 230 frame #24: 0x0000000109c2c747 UIKitCore`-[_UIDeepestPreferredEnvironmentSearch deepestPreferredFocusableItemForEnvironment:withRequest:] + 817 frame #25: 0x0000000109c95837 UIKitCore`-[UIFocusUpdateContext _updateDestinationItemIfNeeded] + 265 frame #26: 0x0000000109c95627 UIKitCore`-[UIFocusUpdateContext _destinationItemInfo] + 22 frame #27: 0x0000000109c95535 UIKitCore`-[UIFocusUpdateContext nextFocusedItem] + 24 frame #28: 0x0000000109c71ea6 UIKitCore`-[UIFocusSystem updateFocusIfNeeded] + 1347 frame #29: 0x0000000109c7608c UIKitCore`__43-[UIFocusSystem _updateFocusUpdateThrottle]_block_invoke + 34 frame #30: 0x000000010a94b971 UIKitCore`-[_UIAfterCACommitBlock run] + 57 frame #31: 0x000000010a94be71 UIKitCore`-[_UIAfterCACommitQueue flush] + 191 frame #32: 0x000000010a3926eb UIKitCore`_runAfterCACommitDeferredBlocks + 782 frame #33: 0x000000010a380fa2 UIKitCore`_cleanUpAfterCAFlushAndRunDeferredBlocks + 96 frame #34: 0x000000010a3b6be1 UIKitCore`_afterCACommitHandler + 58 frame #35: 0x00007ff8003b1c12 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 frame #36: 0x00007ff8003ac57f CoreFoundation`__CFRunLoopDoObservers + 515 frame #37: 0x00007ff8003acaa2 CoreFoundation`__CFRunLoopRun + 1121 frame #38: 0x00007ff8003ac264 CoreFoundation`CFRunLoopRunSpecific + 560 frame #39: 0x00007ff8003ad234 CoreFoundation`CFRunLoopRun + 40 frame #40: 0x00007ff83755a4e3 libswift_Concurrency.dylib`swift_task_asyncMainDrainQueueImpl() + 35 frame #41: 0x00007ff83755a4b4 libswift_Concurrency.dylib`swift_task_asyncMainDrainQueue + 52 frame #42: 0x00000001015d409f $__lldb_expr32`main at <unknown>:0 frame #43: 0x0000000100e25560 EnumeratedContactsCNContact`linkResources + 256 frame #44: 0x00007ff8003b2986 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12 frame #45: 0x00007ff8003b2148 CoreFoundation`__CFRunLoopDoBlocks + 399 frame #46: 0x00007ff8003ace09 CoreFoundation`__CFRunLoopRun + 1992 frame #47: 0x00007ff8003ac264 CoreFoundation`CFRunLoopRunSpecific + 560 frame #48: 0x00007ff809b4024e GraphicsServices`GSEventRunModal + 139 frame #49: 0x000000010a3827bf UIKitCore`-[UIApplication _run] + 994 frame #50: 0x000000010a3875de UIKitCore`UIApplicationMain + 123 * frame #51: 0x0000000100e256c5 EnumeratedContactsCNContact`main + 357 frame #52: 0x0000000100fbb384 dyld_sim`start_sim + 10 frame #53: 0x000000010943341f dyld`start + 1903```
0
1
1.4k
Jun ’23
CNContactStore.currentHistory always nil on iOS 13,14 both Swift and ObjC
Hi, Im using the CNContactStore.currentHistory (available from iOS 13) to get token and check version of contacts. Everything is good til I try it on iOS 13 and iOS 14. Token is always nil from both ObjC and Swift. Is it a bug? Or have any way to handle that instead? Have any way to get token in iOS 13, 14? Any help would be greatly appreciated. Thank you!
1
0
615
Jun ’23
Identify CNContact record from multiple devices
If I have located (or created) a CNContact record on one device (e.g., iPhone), and I want to retrieve that same record programmatically from another device (e.g., iPad or Mac), is there any unique id that identifies that record? The identifier property on CNContact seems to be assigned for the local replica of the contact record, but I don't believe it can be used to retrieve the record on another device (e.g., using unifiedContact(withIdentifier...). I can unifiedContact(matching...) but not guaranteed to get same record if there are multiples with same predicate property values. I'm pretty new to Swift and CNContactStore, so sorry if I'm missing something obvious.
0
0
1k
Jun ’23
iPhone Demo Contacts vCard File
We are developing an app that will show contact information - name, phone numbers, email addresses, and physical addresses. When I prepare screen shots and 30 second videos for the Apple App Store listing, for privacy, I want to avoid showing contact information from my own personal contacts.  I understand that someone (maybe an Apple engineer) developed a vCard file with 60 iPhone Demo Contacts with "John Appleseed" and others. Does anyone know how I can obtain a zip file for those Demo Contacts, or something similar, in English? I understand the vCard file with 60 contacts was previously, but no longer, available for download as a 5.2 MB zip file on TUAW.
1
0
1.5k
Jun ’23
Fetch user's name, image data on iPhone
Hi! Every One. I want to get user's name, image data on iPhone I had two solution. but all of that failed. First, I access Contacts, And then get just only my card. but cannot get my card. There is no idea that which is my card among all contacts. (CNContact.predicateForContacts(withIdentifiers:)) Second, I login with AppleID, And then get name and image data associated with AppleID. But I cannot get image data. (ASAuthorizationAppleIDCredential) Could you help me?
0
0
702
Jun ’23
Read only container error attempting to create a contact group
Without exception, every single code example/tutorial for adding a contact group uses a nil container value i.e. the toContainerWithIdentifier parameter is nil, as below. I've not been able to find an example usage where it isn't nil. let group = CNMutableGroup() group.name = "whatever" let saveRequest = CNSaveRequest() saveRequest.add(group, toContainerWithIdentifier: nil) do { try store.execute(saveRequest) } catch { handle error } I've been running this code and 99.9% of the time it works as expected. However on one handset the catch is being executed with Error Domain=CNErrorDomain Code=207 "Container is read-only" How should I deal with this? How can I find out what container it is being added to? Why would it be read only? If nil means add to the default container, why is the default container in this case read only? How can I change the code that it will always run on every device? I've not been able to find any examples/tutorials for creating a custom container to which the group can be added.
0
0
785
May ’23
Localized CNPostalAddress field labels
How can I extract the localized field labels on per-CNPostalAddress instance? For example, if I the following: let address1 = CNMutablePostalAddress() address1.isoCountryCode = "US" let address2 = CNMutablePostalAddress() address2.isoCountryCode = "CA" How can I extract the State string from address1 and Province string from address2?
0
0
631
Apr ’23
How long does the review for the Contact Notes Entitlement take?
Hi, about three weeks ago I requested the Contact Notes Field Access Entitlement, so that my macOS app can continue to access notes under Ventura and later. Does anyone know how long it usually takes until the request is processed? It is about three weeks now and I am getting a bit nervous... For the request I filled out the form here: https://developer.apple.com/contact/request/contact-note-field I didn't get any email and only the "Thank you, don't call us, we will call you" style message on the forms website... Is that how it is supposed to work? Is there any way to track the request? Thanks!
1
0
1.2k
Apr ’23
Contact access in list and detail contact view showing error: cannot find ContactDetailView(contact:) in scope.
Hello Everyone please let me know what is wrong in this code. // ContactViewModel.swift import Foundation import Contacts import UIKit final class ContactViewModel : ObservableObject { @Published var contacts : [Contact] = [] @Published var permissionsError : PermissionsError? = .none init() { permissions() } func openSetting() { permissionsError = .none guard let settingsURL = URL(string: UIApplication.openSettingsURLString) else { return } if UIApplication.shared.canOpenURL(settingsURL) { UIApplication.shared.open(settingsURL)} } private func getContacts() { Contact.fetchAll{ [weak self] result in guard let self = self else { return } switch result { case .success(let fetchedContacts): DispatchQueue.main.async { self.contacts = fetchedContacts.sorted(by: {$0.lastName < $1.lastName }) } case .failure(let error): self.permissionsError = .fetchError(error) } } } private func permissions() { switch CNContactStore.authorizationStatus(for: .contacts) { case .authorized: getContacts() case .notDetermined, .restricted, .denied: CNContactStore().requestAccess(for: .contacts) { [weak self] granted, error in guard let self = self else { return } switch granted { case true: self.getContacts() case false: DispatchQueue.main.async { self.permissionsError = .userError } } } default: fatalError("Unknown Error!") } } } // ContactModel.swift import Contacts import UIKit struct Contact:Identifiable { var id: String { contact.identifier} var firstName: String {contact.givenName} var lastName: String {contact.familyName} var phone: String? {contact.phoneNumbers.map(.value).first?.stringValue} var contactImage: UIImage? let contact: CNContact static func fetchAll(_ completion: @escaping(Result<[Contact], Error>) -> Void) { let containerID = CNContactStore().defaultContainerIdentifier() let predicate = CNContact.predicateForContactsInContainer(withIdentifier: containerID) let keysToFetch = [ CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey, CNContactPhoneNumbersKey, CNContactPostalAddressesKey, CNContactImageDataAvailableKey, CNContactThumbnailImageDataKey ] as [CNKeyDescriptor] let request = CNContactFetchRequest(keysToFetch: keysToFetch as [CNKeyDescriptor]) let descriptor = [ CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey, CNContactPhoneNumbersKey, CNContactPostalAddressesKey, CNContactImageDataAvailableKey, CNContactThumbnailImageDataKey ] as [CNKeyDescriptor] do{ let rawContacts = try CNContactStore().unifiedContacts(matching: predicate, keysToFetch: descriptor) completion(.success(rawContacts.map{.init(contact:$0)})) } catch { completion(.failure(error)) } } } enum PermissionsError: Identifiable { var id:String { UUID().uuidString } case userError case fetchError(_:Error) var description: String { switch self { case .userError: return "Please change permissions in settings." case .fetchError(let error): return error.localizedDescription } } } // ContactsView.swift import SwiftUI struct ContactsView: View { @StateObject var contactsVM = ContactViewModel() let alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"] var body: some View { NavigationStack { VStack { ScrollViewReader { scrollProxy in ZStack { contactsList(scrollProxy: scrollProxy) VStack { ForEach(alphabet, id: \.self) { letter in HStack { Spacer() Button(action: { print("letter = \(letter)") if contactsVM.contacts.first(where: { $0.firstName.prefix(1) == letter }) != nil { withAnimation { scrollProxy.scrollTo(letter) } } }, label: { Text(letter) }) } } } } } } .alert(item: $contactsVM.permissionsError) { _ in Alert( title: Text("Permission denied"), message: Text(contactsVM.permissionsError?.description ?? "unknown error"), dismissButton: .default(Text("OK"), action: {contactsVM.openSetting()})) } .navigationTitle("Contacts") } } @ViewBuilder private func contactsList(scrollProxy: ScrollViewProxy) -> some View { List { ForEach(contactsVM.contacts.sorted(by: { $0.firstName < $1.firstName })) { contact in contactSection(contact: contact) } } } // MARK: - Contact Section @ViewBuilder private func contactSection(contact: Contact) -> some View { Section(header: Text(String(contact.firstName.first ?? "?"))) { NavigationLink(destination: ContactDetailView(contact:contact)) { VStack(alignment: .leading){ HStack { Text(contact.firstName) } } } } } } struct ContactsView_Previews: PreviewProvider { static var previews: some View { ContactsView() } } Here is my ContactDetailView.swift import SwiftUI struct ContactDetailView: View { let contact : Contact var body: some View { Text(contact.firstName) } } struct ContactDetailView_Previews: PreviewProvider { static var previews: some View { ContactDetailView(contact:contact) } }
1
0
988
Apr ’23
Only used EventKit's calendarsForEntityType API, but a user trigger the address book privacy alert
Only used EventKit's calendarsForEntityType API, but a user trigger the address book privacy alert. Is it possible for EventKit to trigger the privacy alert of the address book?
Replies
0
Boosts
0
Views
831
Activity
Jul ’23
CNContact identifiers
Hi,I saw the WWDC talk on the new Contacts framework, and I had a couple of questions about the identifier property:When users upgrade from iOS8 to iOS9, will their old AddressBook recordIDs still work if we are using the AddressBook framework in the app (i.e. haven't upgraded to using Contacts framework)?Are the new CNContact identifiers consistent across iOS and Mac devices? i.e. if we have the identifier on one device, we can lookup the contact on another device with the same identifier?Can these identifiers change in the lifetime of that contact? This was a problem with AddressBook recordIDs ... if you removed the account and then synced it back again, all the contacts would get a different identifier. Same with restoring the device. Will the CNGroup and CNContainer identifiers also be consistent across devices?Hope someone in the Apple Contacts frameworks team can answer. Thanks.
Replies
6
Boosts
0
Views
4.7k
Activity
Jul ’23
Unable to retrieve contacts from a linked Exchange account
On my iPhone, in Settings, I've added my company Exchange account. Consequently, within the Contacts app, 4 new lists appear - the bottom as shown in the attached image. There's a few thousand contacts in the Company Exchange account, so why are the count values showing as 0? If I click on the Global Address list and search, it can succfully find whatever I search for. I want to programatically retrieve the contacts within the Exchange account, in addition to those stored locally or within iCloud, however if I execute the following code, for the container of type exchange, the count of results of the call to unifiedContacts() is 0. How can I programatically get the Exchange contacts? If the call to unifiedContacts() is resulting in 0 because the count for the lists when viewing the Contacts app is 0, then how to make it not 0 in the Contacts app (but if that were the case, how come manually searching for a contact is successful?) let keysToFetch = [ CNContactFormatter.descriptorForRequiredKeys(for: .fullName), CNContactPhoneNumbersKey, CNContactEmailAddressesKey, CNContactThumbnailImageDataKey] as [Any] var allContainers: [CNContainer] = [] do { allContainers = try CNContactStore().containers(matching: nil) } catch { print("Error fetching containers") } var results: [CNContact] = [] for container in allContainers { let type = container.type let identifier = container.identifier let fetchPredicate = CNContact.predicateForContactsInContainer(withIdentifier: container.identifier) do { let containerResults = try CNContactStore().unifiedContacts(matching: fetchPredicate, keysToFetch: keysToFetch as! [CNKeyDescriptor]) let count = containerResults.count results.append(contentsOf: containerResults) } catch { print("Error fetching containers") } }
Replies
0
Boosts
0
Views
693
Activity
Jul ’23
Apple pay shipping details and contact info
Hi, we are using following setting in our web app to capture customer contact/shipping details: we have selected "detailed request" from "Apple pay payment request" It leads to parsing of following data: However, we do not need the **postal address, ** just email and contact is enough. The problem is in many cases users have not added a shipping address to their apple account, which leads to this screen in case they try to pay: Is it possible to just ask users for "contact number" and "email address" and EXCLUDE asking shipping address which they might have not added, so the payment goes through even if the user has not updated the "address".
Replies
0
Boosts
0
Views
952
Activity
Jul ’23
Playground execution failed: error: Execution was interrupted, reason: shared-library-event.
Why did I get an error in playground in debug window for this code? print("// MARK: - Start execable code here...") do { let store = CNContactStore() if try await store.requestAccess(for: .contacts) { // Do something with Contacts. let phoneNumber = CNPhoneNumber(stringValue: "903-276-1046") let predicateForContactsMatchingPhoneNumber = CNContact.predicateForContacts(matching: phoneNumber) let contactFetchRequest = CNContactFetchRequest(keysToFetch: thoroughKeysToCompare) contactFetchRequest.predicate = predicateForContactsMatchingPhoneNumber contactFetchRequest.unifyResults = true var contactOfMe: CNContact! = nil try! store.enumerateContacts(with: contactFetchRequest) { contact, stop in contactOfMe = contact stop.pointee = true } let contact = Contact(cnContact: contactOfMe) for property in contact.enumerated() { print("- \(property)") } } else { // Handle if Contacts access is denied. fatalError() } } catch { // Handle any error. print("error requesting access: \(error.localizedDescription)") } Debug window: // MARK: - Start execable code here... Playground execution failed: error: Execution was interrupted, reason: shared-library-event. The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation. * thread #1, queue = 'com.apple.main-thread' frame #0: 0x00007ff80002f931 libobjc.A.dylib`_mapStrHash(_NXMapTable*, void const*) + 73 frame #1: 0x00007ff80002fc7f libobjc.A.dylib`_NXMapMember(_NXMapTable*, void const*, void**) + 35 frame #2: 0x00007ff80003b7ae libobjc.A.dylib`getProtocol(char const*) + 41 frame #3: 0x00007ff8000428e6 libobjc.A.dylib`class_conformsToProtocol + 337 frame #4: 0x00007ff80004ab4e libobjc.A.dylib`-[NSObject conformsToProtocol:] + 47 frame #5: 0x0000000109c27951 UIKitCore`_UIFocusItemContainerIsScrollableContainer + 74 frame #6: 0x0000000109c28e38 UIKitCore`-[_UIFocusEnvironmentContainerTuple initWithOwningEnvironment:itemContainer:] + 194 frame #7: 0x0000000109c28fed UIKitCore`+[_UIFocusEnvironmentContainerTuple tupleWithOwningEnvironment:itemContainer:] + 70 frame #8: 0x0000000109c4f41e UIKitCore`_UIFocusRegionContainerFromEnvironmentAndContainer + 44 frame #9: 0x0000000109c27ed3 UIKitCore`_UIFocusItemContainerAddChildItemsInContextWithArguments + 1162 frame #10: 0x000000010a99c439 UIKitCore`-[UIView _searchForFocusRegionsInContext:] + 962 frame #11: 0x0000000109c6b37f UIKitCore`-[_UIFocusMapSnapshot addRegionsInContainer:] + 4583 frame #12: 0x0000000109c69740 UIKitCore`-[_UIFocusMapSnapshot _capture] + 456 frame #13: 0x0000000109c67fc5 UIKitCore`-[_UIFocusMapSnapshot _initWithSnapshotter:mapArea:searchArea:] + 628 frame #14: 0x0000000109c6cce2 UIKitCore`-[_UIFocusMapSnapshotter captureSnapshot] + 227 frame #15: 0x0000000109c5f450 UIKitCore`-[_UIFocusMap _inferredDefaultFocusItemInEnvironment:] + 147 frame #16: 0x0000000109c2b1cf UIKitCore`-[_UIFocusEnvironmentPreferenceEnumerationContext _inferPreferencesForEnvironment:] + 157 frame #17: 0x0000000109c2abbc UIKitCore`-[_UIFocusEnvironmentPreferenceEnumerationContext _resolvePreferredFocusEnvironments] + 118 frame #18: 0x0000000109c2ab12 UIKitCore`-[_UIFocusEnvironmentPreferenceEnumerationContext prefersNothingFocused] + 31 frame #19: 0x0000000109c2beeb UIKitCore`_enumeratePreferredFocusEnvironments + 198 frame #20: 0x0000000109c2c061 UIKitCore`_enumeratePreferredFocusEnvironments + 572 frame #21: 0x0000000109c2c061 UIKitCore`_enumeratePreferredFocusEnvironments + 572 frame #22: 0x0000000109c2c061 UIKitCore`_enumeratePreferredFocusEnvironments + 572 frame #23: 0x0000000109c2bd11 UIKitCore`-[_UIFocusEnvironmentPreferenceEnumerator enumeratePreferencesForEnvironment:usingBlock:] + 230 frame #24: 0x0000000109c2c747 UIKitCore`-[_UIDeepestPreferredEnvironmentSearch deepestPreferredFocusableItemForEnvironment:withRequest:] + 817 frame #25: 0x0000000109c95837 UIKitCore`-[UIFocusUpdateContext _updateDestinationItemIfNeeded] + 265 frame #26: 0x0000000109c95627 UIKitCore`-[UIFocusUpdateContext _destinationItemInfo] + 22 frame #27: 0x0000000109c95535 UIKitCore`-[UIFocusUpdateContext nextFocusedItem] + 24 frame #28: 0x0000000109c71ea6 UIKitCore`-[UIFocusSystem updateFocusIfNeeded] + 1347 frame #29: 0x0000000109c7608c UIKitCore`__43-[UIFocusSystem _updateFocusUpdateThrottle]_block_invoke + 34 frame #30: 0x000000010a94b971 UIKitCore`-[_UIAfterCACommitBlock run] + 57 frame #31: 0x000000010a94be71 UIKitCore`-[_UIAfterCACommitQueue flush] + 191 frame #32: 0x000000010a3926eb UIKitCore`_runAfterCACommitDeferredBlocks + 782 frame #33: 0x000000010a380fa2 UIKitCore`_cleanUpAfterCAFlushAndRunDeferredBlocks + 96 frame #34: 0x000000010a3b6be1 UIKitCore`_afterCACommitHandler + 58 frame #35: 0x00007ff8003b1c12 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 frame #36: 0x00007ff8003ac57f CoreFoundation`__CFRunLoopDoObservers + 515 frame #37: 0x00007ff8003acaa2 CoreFoundation`__CFRunLoopRun + 1121 frame #38: 0x00007ff8003ac264 CoreFoundation`CFRunLoopRunSpecific + 560 frame #39: 0x00007ff8003ad234 CoreFoundation`CFRunLoopRun + 40 frame #40: 0x00007ff83755a4e3 libswift_Concurrency.dylib`swift_task_asyncMainDrainQueueImpl() + 35 frame #41: 0x00007ff83755a4b4 libswift_Concurrency.dylib`swift_task_asyncMainDrainQueue + 52 frame #42: 0x00000001015d409f $__lldb_expr32`main at <unknown>:0 frame #43: 0x0000000100e25560 EnumeratedContactsCNContact`linkResources + 256 frame #44: 0x00007ff8003b2986 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12 frame #45: 0x00007ff8003b2148 CoreFoundation`__CFRunLoopDoBlocks + 399 frame #46: 0x00007ff8003ace09 CoreFoundation`__CFRunLoopRun + 1992 frame #47: 0x00007ff8003ac264 CoreFoundation`CFRunLoopRunSpecific + 560 frame #48: 0x00007ff809b4024e GraphicsServices`GSEventRunModal + 139 frame #49: 0x000000010a3827bf UIKitCore`-[UIApplication _run] + 994 frame #50: 0x000000010a3875de UIKitCore`UIApplicationMain + 123 * frame #51: 0x0000000100e256c5 EnumeratedContactsCNContact`main + 357 frame #52: 0x0000000100fbb384 dyld_sim`start_sim + 10 frame #53: 0x000000010943341f dyld`start + 1903```
Replies
0
Boosts
1
Views
1.4k
Activity
Jun ’23
CNContactStore.currentHistory always nil on iOS 13,14 both Swift and ObjC
Hi, Im using the CNContactStore.currentHistory (available from iOS 13) to get token and check version of contacts. Everything is good til I try it on iOS 13 and iOS 14. Token is always nil from both ObjC and Swift. Is it a bug? Or have any way to handle that instead? Have any way to get token in iOS 13, 14? Any help would be greatly appreciated. Thank you!
Replies
1
Boosts
0
Views
615
Activity
Jun ’23
Identify CNContact record from multiple devices
If I have located (or created) a CNContact record on one device (e.g., iPhone), and I want to retrieve that same record programmatically from another device (e.g., iPad or Mac), is there any unique id that identifies that record? The identifier property on CNContact seems to be assigned for the local replica of the contact record, but I don't believe it can be used to retrieve the record on another device (e.g., using unifiedContact(withIdentifier...). I can unifiedContact(matching...) but not guaranteed to get same record if there are multiples with same predicate property values. I'm pretty new to Swift and CNContactStore, so sorry if I'm missing something obvious.
Replies
0
Boosts
0
Views
1k
Activity
Jun ’23
iOS 17: No programatic accèss to contacts' posters?
You can programatically get/set a picture and a thumbnail for a contact, however the new poster field added to iOS 17 apparently has no programatic access? I'm not able to see anything new being added to CNContact.h
Replies
2
Boosts
4
Views
1.1k
Activity
Jun ’23
iPhone Demo Contacts vCard File
We are developing an app that will show contact information - name, phone numbers, email addresses, and physical addresses. When I prepare screen shots and 30 second videos for the Apple App Store listing, for privacy, I want to avoid showing contact information from my own personal contacts.  I understand that someone (maybe an Apple engineer) developed a vCard file with 60 iPhone Demo Contacts with "John Appleseed" and others. Does anyone know how I can obtain a zip file for those Demo Contacts, or something similar, in English? I understand the vCard file with 60 contacts was previously, but no longer, available for download as a 5.2 MB zip file on TUAW.
Replies
1
Boosts
0
Views
1.5k
Activity
Jun ’23
Ability for CallKit apps create Posters?
In the WWDC, there was a mention of the CallKit framework that it would be possible for 3rd party VoIP apps to create Posters programmatically. However, there are no new methods around this in the CallKit framework. Are we missing something?
Replies
0
Boosts
3
Views
696
Activity
Jun ’23
Fetch user's name, image data on iPhone
Hi! Every One. I want to get user's name, image data on iPhone I had two solution. but all of that failed. First, I access Contacts, And then get just only my card. but cannot get my card. There is no idea that which is my card among all contacts. (CNContact.predicateForContacts(withIdentifiers:)) Second, I login with AppleID, And then get name and image data associated with AppleID. But I cannot get image data. (ASAuthorizationAppleIDCredential) Could you help me?
Replies
0
Boosts
0
Views
702
Activity
Jun ’23
Enroll Unable to continue contact support
Hi Team pls help with this cuz we've been stucking in the contact thing like a month...and we cant get any further progress. We have wrote like 10 emails with our phone numbers but still got no calls at all.
Replies
1
Boosts
0
Views
670
Activity
Jun ’23
TN3149: Fetching Contacts change history events
Learn how to fetch and process the most recent changes to the Contacts database. View Technote TN3149 >
Replies
0
Boosts
0
Views
869
Activity
Jun ’23
Unable to read contacts in Microsoft Office 365 in debug build
I use CNContactStore enumerateContacts to read all contacts, https://fburl.com/9plmcenx Surprisedly, I cannot get contacts synced from Microsoft Office 365 using this API from debug build, release build works. I am wondering what might be the reason? Contacts synced from gmail, or saved locally are read fine in both debug build and release build.
Replies
0
Boosts
0
Views
423
Activity
Jun ’23
Read only container error attempting to create a contact group
Without exception, every single code example/tutorial for adding a contact group uses a nil container value i.e. the toContainerWithIdentifier parameter is nil, as below. I've not been able to find an example usage where it isn't nil. let group = CNMutableGroup() group.name = "whatever" let saveRequest = CNSaveRequest() saveRequest.add(group, toContainerWithIdentifier: nil) do { try store.execute(saveRequest) } catch { handle error } I've been running this code and 99.9% of the time it works as expected. However on one handset the catch is being executed with Error Domain=CNErrorDomain Code=207 "Container is read-only" How should I deal with this? How can I find out what container it is being added to? Why would it be read only? If nil means add to the default container, why is the default container in this case read only? How can I change the code that it will always run on every device? I've not been able to find any examples/tutorials for creating a custom container to which the group can be added.
Replies
0
Boosts
0
Views
785
Activity
May ’23
Is it possible to access contacts in a global address list?
I've linked my contacts app on my iPhone to my company contacts database, and it shows up in the contacts app as "My Company Global Address List", and I can tap on it and search within it. However using CNContactFetchRequest doesn't retrieve any of those contacts, is it something that's possible to do, if so how?
Replies
0
Boosts
0
Views
485
Activity
May ’23
Localized CNPostalAddress field labels
How can I extract the localized field labels on per-CNPostalAddress instance? For example, if I the following: let address1 = CNMutablePostalAddress() address1.isoCountryCode = "US" let address2 = CNMutablePostalAddress() address2.isoCountryCode = "CA" How can I extract the State string from address1 and Province string from address2?
Replies
0
Boosts
0
Views
631
Activity
Apr ’23
"Take photo" option is not displaying in CNContactViewController while setting contact image
"Take photo" option is not displaying while setting the contact image using CNContactViewController in iOS 12, but i can able to see in updated OS Version(13,14). in iOS 12 i can see only one "Choose from gallery" option but in iOS 13 and above i can see "Take Photo" and "choose from gallery" two options
Replies
1
Boosts
1
Views
940
Activity
Apr ’23
How long does the review for the Contact Notes Entitlement take?
Hi, about three weeks ago I requested the Contact Notes Field Access Entitlement, so that my macOS app can continue to access notes under Ventura and later. Does anyone know how long it usually takes until the request is processed? It is about three weeks now and I am getting a bit nervous... For the request I filled out the form here: https://developer.apple.com/contact/request/contact-note-field I didn't get any email and only the "Thank you, don't call us, we will call you" style message on the forms website... Is that how it is supposed to work? Is there any way to track the request? Thanks!
Replies
1
Boosts
0
Views
1.2k
Activity
Apr ’23
Contact access in list and detail contact view showing error: cannot find ContactDetailView(contact:) in scope.
Hello Everyone please let me know what is wrong in this code. // ContactViewModel.swift import Foundation import Contacts import UIKit final class ContactViewModel : ObservableObject { @Published var contacts : [Contact] = [] @Published var permissionsError : PermissionsError? = .none init() { permissions() } func openSetting() { permissionsError = .none guard let settingsURL = URL(string: UIApplication.openSettingsURLString) else { return } if UIApplication.shared.canOpenURL(settingsURL) { UIApplication.shared.open(settingsURL)} } private func getContacts() { Contact.fetchAll{ [weak self] result in guard let self = self else { return } switch result { case .success(let fetchedContacts): DispatchQueue.main.async { self.contacts = fetchedContacts.sorted(by: {$0.lastName < $1.lastName }) } case .failure(let error): self.permissionsError = .fetchError(error) } } } private func permissions() { switch CNContactStore.authorizationStatus(for: .contacts) { case .authorized: getContacts() case .notDetermined, .restricted, .denied: CNContactStore().requestAccess(for: .contacts) { [weak self] granted, error in guard let self = self else { return } switch granted { case true: self.getContacts() case false: DispatchQueue.main.async { self.permissionsError = .userError } } } default: fatalError("Unknown Error!") } } } // ContactModel.swift import Contacts import UIKit struct Contact:Identifiable { var id: String { contact.identifier} var firstName: String {contact.givenName} var lastName: String {contact.familyName} var phone: String? {contact.phoneNumbers.map(.value).first?.stringValue} var contactImage: UIImage? let contact: CNContact static func fetchAll(_ completion: @escaping(Result<[Contact], Error>) -> Void) { let containerID = CNContactStore().defaultContainerIdentifier() let predicate = CNContact.predicateForContactsInContainer(withIdentifier: containerID) let keysToFetch = [ CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey, CNContactPhoneNumbersKey, CNContactPostalAddressesKey, CNContactImageDataAvailableKey, CNContactThumbnailImageDataKey ] as [CNKeyDescriptor] let request = CNContactFetchRequest(keysToFetch: keysToFetch as [CNKeyDescriptor]) let descriptor = [ CNContactGivenNameKey, CNContactFamilyNameKey, CNContactEmailAddressesKey, CNContactPhoneNumbersKey, CNContactPostalAddressesKey, CNContactImageDataAvailableKey, CNContactThumbnailImageDataKey ] as [CNKeyDescriptor] do{ let rawContacts = try CNContactStore().unifiedContacts(matching: predicate, keysToFetch: descriptor) completion(.success(rawContacts.map{.init(contact:$0)})) } catch { completion(.failure(error)) } } } enum PermissionsError: Identifiable { var id:String { UUID().uuidString } case userError case fetchError(_:Error) var description: String { switch self { case .userError: return "Please change permissions in settings." case .fetchError(let error): return error.localizedDescription } } } // ContactsView.swift import SwiftUI struct ContactsView: View { @StateObject var contactsVM = ContactViewModel() let alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"] var body: some View { NavigationStack { VStack { ScrollViewReader { scrollProxy in ZStack { contactsList(scrollProxy: scrollProxy) VStack { ForEach(alphabet, id: \.self) { letter in HStack { Spacer() Button(action: { print("letter = \(letter)") if contactsVM.contacts.first(where: { $0.firstName.prefix(1) == letter }) != nil { withAnimation { scrollProxy.scrollTo(letter) } } }, label: { Text(letter) }) } } } } } } .alert(item: $contactsVM.permissionsError) { _ in Alert( title: Text("Permission denied"), message: Text(contactsVM.permissionsError?.description ?? "unknown error"), dismissButton: .default(Text("OK"), action: {contactsVM.openSetting()})) } .navigationTitle("Contacts") } } @ViewBuilder private func contactsList(scrollProxy: ScrollViewProxy) -> some View { List { ForEach(contactsVM.contacts.sorted(by: { $0.firstName < $1.firstName })) { contact in contactSection(contact: contact) } } } // MARK: - Contact Section @ViewBuilder private func contactSection(contact: Contact) -> some View { Section(header: Text(String(contact.firstName.first ?? "?"))) { NavigationLink(destination: ContactDetailView(contact:contact)) { VStack(alignment: .leading){ HStack { Text(contact.firstName) } } } } } } struct ContactsView_Previews: PreviewProvider { static var previews: some View { ContactsView() } } Here is my ContactDetailView.swift import SwiftUI struct ContactDetailView: View { let contact : Contact var body: some View { Text(contact.firstName) } } struct ContactDetailView_Previews: PreviewProvider { static var previews: some View { ContactDetailView(contact:contact) } }
Replies
1
Boosts
0
Views
988
Activity
Apr ’23