Registering caller id via CXCallDirectoryManager

is it possible to prioritise the app contact over the device contacts while registering caller id via CXCallDirectoryManager ?

If i'm registering a phone number with name john from my app. it that phone number is already mapped to name johny. then johny is displayed as callerid. Any way to prioritise the app's caller id.

The fact it's matching the number to your first local contact number is true and undeniable. Other facts are not so known and clear.

You can update this entry by using CXCallUpdate, because it lets you change what you finally can see in your device's recent calls.

You can juggle with a type of remoteHandle: CXHandle on CXCallUpdate whenever you want. It hack works only when your call is visible in CallKit.

    // Use this init for every new incoming call
    // callerNumber - Use it only when a second party has been changed and we need to update callerName and callerNumber at the same time
    convenience init(callerName: String, hasVideo: Bool, callerNumber: String? = nil) {
        self.init()
        localizedCallerName = callerName
        self.hasVideo = hasVideo

        if let callerNumber = callerNumber {
            // Setting CXHandle.HandleType to .phoneNumber in order to properly connect the passing number from the device's recent history to the app 
            remoteHandle = .init(type: .phoneNumber, value: callerNumber)
        } else {
            remoteHandle = .init(type: .generic, value: callerName)
        }
    }

As you can see .generic type of the remoteHandle is probably what you need. It could change your callerName in the device's recent calls.

This trick doesn't allow you to call back after changing the type of remoteHandle to .generic. If you send an empty or numberless callerNumber you will not able to call back via app.

You can change callerNumber to desired when a call is about to finish to update a number in the device's recent call entry:

     // Use it only when a call is about to finish to update a number in the native recent call entry
    convenience init(callerNumber: String) {
        self.init()
        // Setting CXHandle.HandleType to .phoneNumber in order to properly connect app with native iPhone dialer
        remoteHandle = .init(type: .phoneNumber, value: callerNumber)
    }

You need to choose compromise.

Registering caller id via CXCallDirectoryManager
 
 
Q