How can you access iOS Contacts "found in apps"?

6.4k Views Asked by At

I have an app that uses the Contacts Framework to retrieve information about a user's contacts. If I launch the Apple Contacts app and do a search for some users, I get data about contacts "found in other apps" such as Mail. However, when I try to retrieve all contacts in code, I do not get these users returned.

I am retrieving contact information using the following code:

let store = CNContactStore()
store.requestAccess(for: .contacts) { (success, error) in
if success == true {
    let keysToFetch: [CNKeyDescriptor] = [
        CNContactFormatter.descriptorForRequiredKeys(for: .fullName),
        CNContactEmailAddressesKey as CNKeyDescriptor,
        CNContactPhoneNumbersKey as CNKeyDescriptor,
        CNContactInstantMessageAddressesKey as CNKeyDescriptor,
        CNContactPostalAddressesKey as CNKeyDescriptor,
        CNContactThumbnailImageDataKey as CNKeyDescriptor]

    let fetchRequest = CNContactFetchRequest(keysToFetch: keysToFetch)
    fetchRequest.mutableObjects = true
    fetchRequest.unifyResults = true
    fetchRequest.sortOrder = .userDefault

    do {
        try store.enumerateContacts(with: fetchRequest, usingBlock: { (contact, stop) -> Void in
        // Process results here...
    } catch {

    }
}

Below is a screenshot of user data in the Contacts app that does NOT show up in the data returned. Note that this data also does not show up in the Contacts app if I just scroll to where they should be. They are only there when I do a search.

Does anyone know how to get access to these contacts "found in other apps" using the Contacts Framework?

enter image description here

0

There are 0 best solutions below