Post not yet marked as solved
Hey everyone,
I'm having trouble finding answers to a few things that the documentation seems to be a little sparse on. I've outlined 3 major ones below:
Under what circumstances do contacts get unified automatically? I've tried creating duplicate contacts and adding duplicate contacts on different containers but they are never unified automatically.
Is there a way to link contacts programmatically? Since the unification process doesn't seem to be consistent we're hoping to be able to do this programmatically.
Can I add a CardDAV account programmatically? I want to make it easier for my users to add an external contacts account without telling them to go to Settings > Contacts > Accounts > Add Account > Other > etc.
I've noticed the upcoming changes in the iOS Beta for contact management and cleanup. Do these include any more automation or detection for Unified Contacts?
Post not yet marked as solved
How to make your app show up in Spotlight’s video call option under contact search? As shown in the attached screenshot. Any tutorial is appreciated.
Post not yet marked as solved
In the contacts app there are contacts included that include "Siri found in Mail". I have an app that includes a directory of contact information. Is it possible to include contacts found in my app to the system?
Post not yet marked as solved
Open an existing contact
Click Edit —> Add Birthday
Select Date and Save
Close the contact app
Come back to the same contact, the birthday is gone.
Post not yet marked as solved
What criteria does Apple use to determine whether a vCard sent for example as an email attachment has a duplicate? I would think there has to be more in common between the duplicates than just the given name and the family name? Does Apple say whether the given name, family name, and address enough similarities to consider two contacts duplicates of each other?
Post not yet marked as solved
We’ve been attempting to reliably update contacts in iCloud and Gmail containers. Having tried several approaches (bulk writes, batched writes, one-by-one writes with sleeps in between, etc.), we’ve found flakiness in all approaches that is never exposed to the app.
Diving a little deeper, we’ve found that this appears to be due to internal server-client failures between iOS and the relevant CardDAV servers.
From our analysis, we seem to be seeing 2 key types of failure:
When the client-server interaction is interrupted, contact update requests appear to be discarded and not resumed for whichever container was currently in progress.
After a variable period of time, the server wipes the newer client state and reverts to an older, stale state.
We’re trying to understand if there is something we are doing wrong with our writes or if this is an iOS level bug.
This is easily reproducible for any device connected to an iCloud or Gmail account with circa. 100+ contacts:
for each container
for each contact in container
create CNSaveRequest
update any field in contact and add to save request
execute save request
Post not yet marked as solved
Is there any way to run code in iOS whenever new information are added to certain contacts in contact store?
If I use Notifications, I would have to have a process running at all times, since contacts are able to be changed by Apple's Contacts app. I have looked at App Extensions and there are no extensions I that can be used.
There is a way to run a background process but I recall that has a limited lifespan. Am I correct about this?
I need to update data in CloudKit that saves contacts information that can be shared with other users using their own Apple ID's. CloudKit subscriptions notify my app when something changes in CloudKit, but I also need to update records in CloudKit when something changes in Contacts.
Anyone have any ideas how this might possibly be done?
Post not yet marked as solved
What does CNContactStoreDidChange notification notify multiple times for a single change my app makes itself?
Post not yet marked as solved
Using:
selectedContacts = contacts.filter ({ $0.birthday?.year != nil })
Code compiles but contact still shows.
How to select the correct data element from the contacts birthday when it doesn’t contain a year?
func contactPicker(_ picker: CNContactPickerViewController, didSelect contacts: [CNContact]) {
//selectedContacts = contacts.filter ({ $0.birthday?.value(for: .year) != nil })
selectedContacts = contacts.filter ({ $0.birthday?.year != nil })
//value(for: .year) != nil })
Post not yet marked as solved
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'.
Post not yet marked as solved
I'm having trouble converting a CNGroup object to a Data object and back to a CNGroup object. I decided to start rethinking the problem again. Somewhere along the way I decided that I should use the Data class to save a CNGroup object to CloudKit. I also learned that the field type to use in my CKRecord object would be of the type bytes.
Am I correct so far?
I am able to convert a CNGroup object to a Data object and back again unless I store the Data object in CloudKit and then retrieve it before I convert the Data object back to a CNGroup object, in which case I get an error when I try to access the pointee property of the typed pointer. That would be an UnsafeBufferPointer, an UnsafeMutableBufferPointer, or an UnsafePointer.
I've tried a lot of different code using different ways. It is impractical to put so much code in my post. I have used the copyBytes method and the withUnsafeBytes method of the Data object.
There is one simple code, and that is when I converted the CNGroup object to a Data object:
func convertCNGroupToData(fromCNGroup group: inout CNGroup) -> Data {
return Data(bytes: &group, count: MemoryLayout.size(ofValue: group))
}
I am looking for a simple way to do what I want. I am relooking at Apple's documentation of Data and NSData.
I am not able to be more specific with this question. I appreciate any effort to help me with this.
Post not yet marked as solved
Hello Everyone,
I requested for the Contact Note Field Access Entitlement here : https://developer.apple.com/contact/request/contact-note-field
It was Approved
I created a new provisioning profile and I can see that I have got the access for Notes filed, in the provisioning profile details.
But when I try to fetch all Notes field it gives me error :
Unauthorized Keys
Can someone please tell me where is the Entitlement file location ? Or do I have to create one ?
Apple told me to wait 2 to 3 days and it will appear in my Account, but they did not specify the exact location?
Where in the account do I have to look for it?
Post not yet marked as solved
Could someone please clarify how to access SmartGroups using the CNContacts framework?
Post not yet marked as solved
I found information about the ABAddressBookRegisterExternalChangeCallback(::_:) function of the Address Book Framework, but that function has been deprecated, and only works with iOS 2.0–9.0. I don't see a function in the Contacts Framework that does what that function does. Is there some way that the Contacts Framework could do something that this function provided a solution for?
Post not yet marked as solved
Is there a way to put code in iOS that is always watching in the background for the contact store to change? If I put it in my app, then the user can close the app, and the app won't receive notifications when the contact store changes? Is there an app extension I can use that would allow me to do this, whether that is the intent of the extension or not?
Post not yet marked as solved
I need to be able to identify a CNContact so as to associate it with a CKRecord in a iCloud private database. If I use a non-unified contact, would the identifier be unique across all existing iOS devices so that I could store the identifier property in a record in the user's iCloud private database to identify a specific contact? The documentation says that the identifier of a CNContact stored object is unique within the device.
If I use a UUID value and store it in the iCloud private database to identify the specific contact, how would I match that with the contact? I would need to save that UUID value as part of the contact object as stored in the contact store. Is that possible without saving the UUID value in the notes property of the contact. It would be better if I could store the UUID value somewhere where the user could not access it and delete or edit it. Is there a way to make the notes property of a contact inaccessible to the user where even if he/she could see it, he would not be able to change it?
I'm not very familiar with the hash and hashValue properties of NSObject object. Though unlikely, would one of those properties be able to identify a contact uniquely across all existing iOS devices so that I could store it in the user's iCloud private database in order to associate a certain record in that database with a specific contact?
Post not yet marked as solved
I had requested for Contact Note Field Access Entitlement (via https://developer.apple.com/contact/request/contact-note-field) and got it enabled in app id's additional capabilities section.
I have created app store distribution provisioning profile using this app id. And also added "com.apple.developer.contacts.notes YES" in entitlements file. But I'm getting the below error in xcode.
I'm not able to archive the build because of this. How can I resolve this issue?
Post not yet marked as solved
This is how I request contacts framework access permission
-(void)askUserToAccessContacts
{
@try
{
if([CNContactStore class])
{
//iOS 9 or later
CNEntityType entityType = CNEntityTypeContacts;
if( [CNContactStore authorizationStatusForEntityType:entityType] == CNAuthorizationStatusNotDetermined)
{
CNContactStore * contactStore = [[CNContactStore alloc] init];
[contactStore requestAccessForEntityType:entityType completionHandler:^(BOOL granted, NSError * _Nullable error) {
if(granted){
DDLogVerbose(@"Permission granted for Contacts access...");
}
}];
}
else if( [CNContactStore authorizationStatusForEntityType:entityType]== CNAuthorizationStatusAuthorized)
{
DDLogVerbose(@"Permission granted for Contacts access !!!");
}
else
{
DDLogVerbose(@"Permission not granted for Contacts access !!!");
}
}
} @catch (NSException *exception) {
[[WriteLogger getWriteLogger] writeLog:@"AppDelegate" sourceClass:NSStringFromClass([self class]) methodName:NSStringFromSelector(_cmd) exception:exception exceptionDict:nil];
}
}
What could possibly cause the app to crash?
By the way, this crash is not occurring all the time, it happens randomly when I install the app and launch it for the first time.
Incident Identifier: 33DC6088-0DC6-40A1-91E5-F7A76E3154EB
Hardware Model: iPhone12,8
Version: 21.10.0 (0.5.2)
AppStoreTools: 13C90b
AppVariant: 1:iPhone12,8:15
Beta: YES
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Date/Time: 2022-01-10 11:43:38.9707 +0530
Launch Time: 2022-01-10 11:43:17.9333 +0530
OS Version: iPhone OS 15.1 (19B74)
Release Type: User
Baseband Version: 3.00.00
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Kernel Triage:
VM - pmap_enter failed with resource shortage
VM - pmap_enter failed with resource shortage
VM - pmap_enter failed with resource shortage
VM - pmap_enter failed with resource shortage
VM - pmap_enter failed with resource shortage
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001b73d0504 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x00000001b73d0b9c mach_msg + 76 (mach_msg.c:119)
2 libdispatch.dylib 0x000000018019127c _dispatch_mach_send_and_wait_for_reply + 520 (mach.c:815)
3 libdispatch.dylib 0x000000018019162c dispatch_mach_send_with_result_and_wait_for_reply + 56 (mach.c:2019)
4 libxpc.dylib 0x00000001f083eb9c xpc_connection_send_message_with_reply_sync + 240 (connection.c:974)
5 TCC 0x00000001e78bb0c0 tccd_send_message + 940 (TCC.c:490)
6 TCC 0x00000001e78c0e08 __TCCAccessRequest_block_invoke.213 + 876 (TCC.c:591)
7 libdispatch.dylib 0x0000000180176660 _dispatch_client_callout + 20 (object.m:560)
8 libdispatch.dylib 0x00000001801858b4 _dispatch_lane_barrier_sync_invoke_and_complete + 56 (queue.c:1016)
9 libsystem_trace.dylib 0x000000019ac86668 _os_activity_initiate_impl + 64 (activity.c:131)
10 TCC 0x00000001e78bc4e0 TCCAccessRequest + 476 (TCC.c:1019)
11 TCC 0x00000001e78ba8b8 TCCAccessRestricted + 228 (TCC.c:1682)
12 ContactsFoundation 0x000000018ce4a6ec -[CNTCCVersion2 isAuthorizationRestricted] + 96 (CNTCCVersion2.m:79)
13 ContactsFoundation 0x000000018ce034a4 -[CNAuthorizationContext isAccessRestricted] + 52 (CNAuthorizationContext.m:90)
14 Contacts 0x0000000185c42b04 +[CNAuthorization isAccessRestrictedForEntityType:] + 72 (CNAuthorization.m:26)
15 Contacts 0x0000000185c5ba30 +[CNAuthorization authorizationStatusForEntityType:] + 40 (CNAuthorization.m:66)
16 ios_app 0x00000001024bc724 -[MainAppDelegate askUserToAccessContacts] + 84 (MainAppDelegate.m:1338)
17 ios_app 0x00000001024b61b8 -[MainAppDelegate application:didFinishLaunchingWithOptions:] + 1520 (MainAppDelegate.m:228)
log.crash
Post not yet marked as solved
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.
Post not yet marked as solved
Xcode 13.2
Using CNContact seeing the error in the log:
...
[framework] Resetting database at nil path is not allowed
....
What does this mean? What causes this to happen?
How do I avoid this?
Any help appreciated!
Steve