Search code examples
iosswiftcallkit

Identify incoming callers with CallKit when they are already contacts


I am creating an app that tracks money owed between friends. I would like to create a feature where incoming calls will show with a warning if that person owes you money.

I am using the Apple-provided approach to identify callers:

class CustomCallDirectoryProvider: CXCallDirectoryProvider {
    override func beginRequest(with context: CXCallDirectoryExtensionContext) {
        let labelsKeyedByPhoneNumber: [CXCallDirectoryPhoneNumber: String] = [ … ]
        for (phoneNumber, label) in labelsKeyedByPhoneNumber.sorted(by: <) {
            context.addIdentificationEntry(withNextSequentialPhoneNumber: phoneNumber, label: label)        
        }

        context.completeRequest()
    }
}

enter image description here

This works great so far for incoming calls. However, if the call is coming from a person that is already in the user's contact list then that name will show and our information will not show.

Is there a way to show our contract information even when the caller is in the user's contact list?


Solution

  • No, data from the CallKit identification extension is only used if there is no match against an existing contact.