Contacts

RSS for tag

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

Posts under Contacts tag

50 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

ContactAccessPicker crashing issue
Given Apple's new .limited contact authorization introduced in ios18, I want to be able to present the ContactAccessPicker directly from my app, via ionic capacitor. I present the .contactAccessPicker view via a UIHostingController, and I manage the view controller's dismissal accordingly when the ContactAccessPicker completes and is no longer presented. Bug: After a few searches or interactions with the Contact Access Picker (ex. searching, selecting contacts, clicking the "show selected" button), the contact access picker crashes and the overlay remains. Any interaction with my app is then blocked because I can't detect that the contact access picker has disappeared when it crashes so I can't dismiss the viewController. Is there a way for me to prevent the contact access picker from crashing, and how can I detect if it does crash, so I can at least dismiss the view controller if that happens? struct ContactAccessPickerView: View { @Binding var isPresented: Bool let completion: @MainActor ([String]) -> Void var body: some View { Group { if #available(iOS 18.0, *) { Color.clear .contactAccessPicker(isPresented: $isPresented) { result in Task { @MainActor in completion(result) } } } else { } } } } @objc func selectMoreContacts(_ call: CAPPluginCall) { guard isContactsPermissionGranted() else { call.resolve(["success": false]) return } // Save the call to ensure it's available until we finish self.bridge?.saveCall(call) DispatchQueue.main.async { [weak self] in guard let self = self else { return } var isPresented = true let picker = ContactAccessPickerView(isPresented: .init(get: { isPresented }, set: { isPresented = $0 })) { contacts in call.resolve(["success": true]) self.dismissAndCleanup(call) } let hostingController = UIHostingController(rootView: picker) hostingController.modalPresentationStyle = .overFullScreen self.bridge?.viewController?.present(hostingController, animated: true) } }
0
1
93
1d
How to Properly Request Full Access to Contacts After User Selects Limited Access?
Hello Apple Developers, I’m developing an iOS app that requires access to the user’s contacts. I understand that starting from iOS 14, Apple introduced two levels of contact permissions: 1️⃣ Full Access – The app can read all contacts. 2️⃣ Limited Access – The app can only access contacts selected by the user. My Question: If a user initially grants Limited Access, is it allowed by Apple’s guidelines to request Full Access later? 🔹 I understand that re-requesting permission immediately after the user denies it is against Apple’s policies. 🔹 However, if the user has already granted Limited Access, and we first show an explanation modal explaining why Full Access is beneficial, can we then prompt them to change their settings via openAppSettings()? 🔹 Alternatively, can we use Permission.contacts.request() again to re-prompt the user for Full Access, or will iOS prevent the permission prompt from appearing again? How We Handle This in the App: 1️⃣ If a user selects Limited Access, we respect their choice and only access their selected contacts. 2️⃣ Later, if Full Access is necessary for an enhanced experience, we display a clear explanation modal explaining why the app needs Full Access. 3️⃣ If the user agrees, we attempt to guide them to openAppSettings(), allowing them to manually change the permission. 4️⃣ However, if Permission.contacts.request() can be used to directly request Full Access again, we would like to know if this is acceptable. We want to ensure that our implementation follows Apple’s privacy guidelines while providing the best user experience. Any official guidance or best practices on this matter would be greatly appreciated. Thank you in advance!
0
0
103
2d
Contacts Framework Question
Hey, I would love to access the users Contact (ie. the Me Card) Apple recently released the Invites app and within this app you can find the users Contacts Photo. I tried to replicate this behaviour but I currently need to match based on a name or email or something else. I have no idea how to receive this data because when using the Invites app I only remember the app asking for Contacts permission and nothing else so far. let store = CNContactStore() let keysToFetch = [CNContactImageDataAvailableKey, CNContactImageDataKey, CNContactThumbnailImageDataKey] as [CNKeyDescriptor] let email = "test@test.de" let predicate = CNContact.predicateForContacts(matchingEmailAddress: email) do { let contacts = try store.unifiedContacts(matching: predicate, keysToFetch: keysToFetch) let imageDatas: [Data] = contacts.compactMap { $0.imageData } self.images = imageDatas.map { UIImage(data: $0) ?? UIImage() } } catch { print("Error fetching contacts: \(error)") } This is how I am retrieving the Image. MAYBE someone can help me out. Thank you so far ~ Flo
0
0
133
1w
CallDirectoryExtention - How to remove a phone number entry that has already been added if a specific value is retrieved.
The App has the ability to use WebKit and display web pages and the ability to add phone numbers to CallDirectory at specific timing. In this App, when the App is launched or when the Add Contact button on the web page is pressed, CallDirectoryExtention is reloaded from the host app (WebKit-viewController), the phone number is retrieved from the server, and the entry is updated. I would like to add a process to remove the already added phone number entry when a specific value is retrieved from the application server. The specific process we wish to implement is as follows. Step 1: Use URLsession to retrieve values from the application server. (ViewController) Step 2: If the value is a specific value, call a Function that deletes the CallDirectoryExtention entry. (ViewController) Step 3: Delete all entries for the registered phone numbers.
 However, I am aware that I have to use reloadExtension() to call the CallDirectoryExtention process from ViewController on Step2. if I do so, CallDirectoryHandler.beginRequest() will be processed, and I am wondering if it is not possible to execute only the Function that deletes the entry. Is there a way to run only the Function that deletes the CallDirectoryExtention entry from the host app(viewController)?
3
0
214
1w
App crash!!!
Phone application is crashing every time I try to update WhatsApp has contact saved on my Iphone12, why? Mobile phone crash report from settings linkText Click on update contact option and you will redirect to review and update page without any data visibility. On clicking this update button, app crashes instantly.
1
0
151
Jan ’25
CallKit - CallDirectory extension - Added data by addIdentificationEntry
The app I'm making uses the CallDirectory extension to identify callers. Where is the contact data added by "func addIdentificationEntry" in "CallDirectory Extension" stored? The app calls "CXCallDirectoryManager.sharedInstance.reloadExtension" and adds contact data by processing "CXCallDirectoryExtensionContext.addIdentificationEntry" written in "func beginRequest" of "CallDirectory Extension". I thought that if I uninstalled the app, I would lose the contact data that added by App. However, when I uninstalled the app and reinstalled it, it seemed to retain contact data that added by App before I uninstalled the app, even though the app hasn't added any contact data yet. Will the contact data added to the "CallDirectory Extension" be retained on iPhone even after uninstalling the app? ---Note--- I found a similar post on the forum about contact data added by addIdentificationEntry. ・CallKit - addIdentificationEntry is it secure? [https://developer.apple.com/forums/thread/662182] Answer of this post that "the added data is cached in a SQLite database", but I couldn't find any official Apple documentation on this, so I'm not sure if this is correct. If contact data is cached in SQLite, will that data remain on the iPhone when uninstalled and not deleted? ●Development environment Mac OS Sonoma 14.7.1 Xcode 16.0 Swift ●Test Device iPhoneSE3 iOS:17.6.1
2
0
449
Jan ’25
App cannot fetch any resource after a while
Hi everyone, We came an issue that, In some scenarios in our app we cannot fetch any resources from device (Photo and Contact). One case we catched is putting app in background and spending time in other commonly used apps and coming back to our app cause this issue but there is a small chance that get this issue during using the application. In cell, we are trying to fetch the image like this imageFetchTask = Task { let image = await CompositionRoot.shared.photosManager.image(requestType: .imageCollections, forId: photoAsset.photoId) self.photoImageView.image(image) } and inner layers of this code we get the PHAsset and request image PHAsset.firstAsset(for: id) let manager = PHImageManager.default() manager.requestImage(for: asset, targetSize: request.targetSize, contentMode: .aspectFill, options: request.options) { (image, info) in continuation.resume(returning: image) } We figured out that issue not happening only in Photos also Contacts and any web request. So any help according to this situation is well appreciated. Thanks
0
0
215
Dec ’24
Seeking Help - Need to Identify Date Contacts Were Added
Saw this info: https://developer.apple.com/documentation/contacts/cncontactstore But have no idea what I'm doing. This is a pressing matter and I need to determine the date/time contacts were originally created on my icloud account. I have tried the shortcuts method and it merely shows the date they were loaded into whichever device i'm logged in on if they were created a while ago
0
0
215
Dec ’24
Accessing Contacts in App
I am developing an app that would like to access the contacts on the user's device. There was a recent article published that said Apple was restricting access to a user's contacts on their device. This was due to some current apps accessing the contacts and using that list for spam email and texts. Is that they case? if so, are there specific cases that allow an App to access the contacts?
2
0
320
Dec ’24
Siri Prioritizing Incorrect Contact When Default Account is Set
Hello, I’m experiencing an issue with Siri on iOS where it prioritizes a contact from the wrong account, even though I’ve set a default account for Contacts. Details of the issue: I have two contact groups: Exchange (Outlook) — my default account. iCloud. There’s a contact, "Alena Jorse," which exists in both groups: In the Exchange group, the name is saved as Alena Jorse. In the iCloud group, it is saved as Alena Jorse with double-strike formatting (e.g., "Alena Jorse**"). Both contacts have the same phone number. When I ask Siri to call "Alena Jorse," it selects the iCloud contact ("Alena Jorse**") instead of the Exchange contact, despite Exchange being set as the default Contacts account in my iOS settings. Expected Behavior: Siri should prioritize the contact from the default account (Exchange) and ignore other accounts unless specified. Steps to Reproduce: Have duplicate contacts in two groups (Exchange and iCloud) with the same phone number. Set Exchange as the default Contacts account. Ask Siri to call the contact. Troubleshooting Steps Taken: Ensured the default account is set to Exchange. Verified both contacts have the same phone number. Tested by disabling iCloud temporarily, which resolves the issue (but is not a viable long-term solution). Request: Could you please advise if this is intended behavior or a bug? If it’s a configuration issue, how can I ensure Siri prioritizes the default account for contacts? If it’s a bug, could this be investigated further? Thank you for your assistance.
1
0
266
Dec ’24
Public Contact Info
I wanted to create a public contact card so when my clients click a button on my website it traverses them through the iMessage API and instantly adds a contact card with photo and name as a background task. If there is implications my next question was going to be if there is a possible way to create a public contact card where for example I could redirect a client to iMessage and when starting a new conversation if they type in a name it pops up instead of needing to utilize a phone number? I am trying to explain my thought process as much as possible but I have been typing for hours. In simple terms is there a possibility to create a public contact card that can be accessed or texted by anyone who types in a name into new conversation bar?
1
0
348
Dec ’24
Contacts: remove member from group not working on macOS
Hi, In my app, I have an option to remove a contact from a contact group (using the Contacts framework), and it's been working fine till recently users of the macOS version reported that it's not working. I have been using the CNSaveRequest removeMember(contact, from: group) API. The same API works fine on iOS. I'm not sure when it started but it seems to be affecting macOS14.6 as well as 15.1. I was able to reproduce it in a small test project as well, and have the same experience (the API works on iOS but not on macOS), so it definitely seems like a problem with the framework. Can someone confirm this, and/or suggest a workaround? Here's the code I run to test it out ...a simple SwiftUI view that has 4 buttons: Create contact and group Add contact to group Remove contact from group (optional) cleanup by deleting contact and group It's the 3rd step that seems to fail on macOS, but works fine on iOS. Here's the code to test it out: struct ContentView: View { let contactsModel = ContactsStoreModel() var body: some View { VStack (alignment: .center, spacing: 15){ Button ("1. Add Contact And Group") { print("add contact button pressed") contactsModel.addTestContact() if let _ = contactsModel.createdContact { print("created contact success") } } Button ("2. Add Contact To Group") { print("add to group button pressed") contactsModel.addContactToGroup() } Button ("3. Remove Contact From Group") { print("remove from group button pressed") contactsModel.removeContactFromGroup() } Button ("4. Delete Contact and Group") { print("remove from group button pressed") contactsModel.deleteContactAndGroup() } } .padding() } } #Preview { ContentView() } @available(iOS 13.0, *) @objc final class ContactsStoreModel: NSObject, ObservableObject { let contactStore = CNContactStore() var createdContact : CNContact? var createdGroup : CNGroup? public func addTestContact() { let storeContainer = contactStore.defaultContainerIdentifier() let contact = CNMutableContact() contact.givenName = "Testing" contact.familyName = "User" contact.phoneNumbers = [CNLabeledValue(label: "Cell", value: CNPhoneNumber(stringValue: "1234567890"))] let group = CNMutableGroup() group.name = "Testing Group" print("create contact id = \(contact.identifier)") print("create group id = \(group.identifier)") do { let saveRequest = CNSaveRequest() saveRequest.transactionAuthor = "TestApp" saveRequest.add(contact, toContainerWithIdentifier: storeContainer) saveRequest.add(group, toContainerWithIdentifier: storeContainer) try contactStore.execute(saveRequest) createdContact = contact createdGroup = group } catch { print("error in store execute = \(error)") } } public func addContactToGroup() { if let contact = createdContact, let group = createdGroup { do { let saveRequest = CNSaveRequest() saveRequest.transactionAuthor = "TestApp" saveRequest.addMember(contact, to: group) try contactStore.execute(saveRequest) } catch { print("error in store execute = \(error)") } } } public func removeContactFromGroup() { if let contact = createdContact, let group = createdGroup { do { let saveRequest = CNSaveRequest() saveRequest.transactionAuthor = "TestApp" saveRequest.removeMember(contact, from: group) try contactStore.execute(saveRequest) } catch { print("error in store execute = \(error)") } } } public func addGroupAndContact() { let storeContainer = contactStore.defaultContainerIdentifier() let group = CNMutableGroup() group.name = "Test Group" print("create group id = \(group.identifier)") if let contact = createdContact { do { let saveRequest = CNSaveRequest() saveRequest.transactionAuthor = "TestApp" saveRequest.add(group, toContainerWithIdentifier: storeContainer) saveRequest.addMember(contact, to: group) try contactStore.execute(saveRequest) createdGroup = group } catch { print("error in store execute = \(error)") } } } public func deleteContactAndGroup() { if let contact = createdContact, let group = createdGroup { do { let mutableGroup = group.mutableCopy() as! CNMutableGroup let mutableContact = contact.mutableCopy() as! CNMutableContact let saveRequest = CNSaveRequest() saveRequest.transactionAuthor = "TestApp" saveRequest.delete(mutableContact) saveRequest.delete(mutableGroup) try contactStore.execute(saveRequest) } catch { print("error in deleting store execute = \(error)") } } } }
1
0
297
Dec ’24
Support Status and Specific Implementation Methods for ContactProviderExtension with NotificationServiceExtension
I am considering an implementation to provide OS Contacts information in real-time using data from push notifications. Through a TSI (Technical Support Incident), Apple Support recommended combining ContactProviderExtension and NotificationServiceExtension. However, the following threads indicate that this combination is not supported, as confirmed by Apple DTS (Thread 1, Thread 2). Question 1: Latest Support Status for Using ContactProviderExtension with NotificationServiceExtension Additionally, there is limited documentation on implementing ContactProviderExtension, and I am specifically struggling with the following points: Question 2: Specific Implementation Guidance for ContactProviderExtension The method to call when providing Contacts information to the OS How to add and delete Contacts information provided to the OS How to verify the Contacts information currently provided to the OS Any insights on the latest support status or specific implementation methods for these extensions would be greatly appreciated.
0
0
352
Nov ’24
Timer driven refresh
I have an app that needs to refresh a server whenever a Contacts record is updated. I can observe Contacts, but that only seems to work when my app is running (and in foreground, which it cannot be on iPhone if the Contacts app is being updated). I want it to process, even if my app is in background, or has been terminated (swiped away), or after a phone restart. The only way I can think of is to periodically push a notification to the app from an external server. Is there any way to run a timer that sends a notification to the app on a periodic basis? The timers you can set seem to run even if the Clock app is swiped away, or following a phone restart. Is there anything like that I could use to wake my app periodically?
1
0
418
Oct ’24
callkit and contact app
Hello, I am a developer currently working on a personal contact management app. What is the app? My app stores additional information beyond basic contact details. Therefore, instead of using the Contacts framework, I manage contact objects using Core Data. What am I trying to achieve? I want to display additional information on the caller ID screen when a call is received from a number stored in my app. What have I tried? I’ve attempted the following methods without success: 1. Call Directory Extension: I thought using this method would allow me to display additional information from Core Data on the call screen. However, I learned that when a call is received, the iOS system first searches for the phone number in the Contacts app and only looks to the Extension app if no match is found. Therefore, displaying contact information from my app seems unfeasible. 2. Custom Call UI: Using CallKit seemed like a viable option to display the necessary information during a call, but it appears to only be possible with VoIP apps. My app does not support VoIP calls, so this method was also not implementable. I am wondering if there are any technologies available that could help me achieve my goal, or if there’s something I might be missing. Any advice would be greatly appreciated. Thank you! If a similar question has been asked, I apologize for the repetition.
3
0
651
Oct ’24