How to debug Call Directory Extension?

I've tried to attach to Phone process (and many others) but incoming call is not hitting breakpoint in CXCallDirectoryProvider.beginRequest

Considering lack of documentation what am I doing wrong?

Thanks in advance!

Replies

Have you found ANY documentation? I can barely it mentioned anywhere.

Not really...

Only basic stuff https://developer.apple.com/reference/callkit


I have high expectations regarding WWDC session 230

https://developer.apple.com/videos/play/wwdc2016/230/

CXCallDirectoryProvider seems to be broken in the first beta.

Calling

CXCallDirectoryManager.sharedInstance.reloadExtension(withIdentifier: "bundleIdentifier", completionHandler: { (error) -> Void in
            if let error = error {
                print(error.localizedDescription)
            }
        })

outputs

sqlite3_prepare_v2 for query 'INSERT OR IGNORE INTO PhoneNumber (number) VALUES ' returned 1 errorMessage 'near " ": syntax error'

for me.


So let's wait for beta 2. 😉

Update: I fixed it. It worked when I pasted some content into both the blocked numbers and the identification entrys.

The format of the telephone number has to be:

+(country code)(phone number)

for example:

+49123456789


But it seems like the app does not get access to the phone number that calls, instead you have to specify the IDs in a database before the caller calls. 😟

@yanniks.


Are you able to get it to hit breakpoints in XCode? I can't even get the XCode extenion template to hit a breakpoint or to NSLog anything in the beginRequest method. So apparently the extension isn't even executing. How did you therefore get it to do that?

Does CXCallDirectoryProvider.beginRequest get called everytime there is an incoming call?

No, the extension doesn't hit breakpoints at all, NSLog doesn't appear anywhere.

Still the extension is executing. I tested it with pasting phone numbers into the code. Before that, I deleted them in my contacts just to make sure that this does not cause any problems.

No, I don't think so since the app doesn't know the phone number that is called.

Can you elaborate a little about how you got it working?


I'm currently getting

The operation couldn’t be completed. (com.apple.CallKit.error.calldirectorymanager error 1.)

all the time when trying to call reloadExtension...


Am I missing some steps that have to be performed beforehand?

Are you 100% sure the label is coming from your extension? If you add a contact entry and then make a call, then delete the contact enty and make a call again, the call screen still displays the name that was in contacts (but it places Maybe in front of it). Is your extension label totally different from what was in contacts?

I've managed to get this working, here's what I did and some observations:


1) Create a new target of Type Call Directory Extension.

2) Edit retrievePhoneNumbersToIdentifyAndLabels() to include the number and label you want. Add +CountryCode at the start (not confirmed yet if this is essential)

3) Run the containing app target.

4) In setting go to Phone/Call Blocking & IdentificationAnd turn on you extension (or it will automatically be turned on if you run the entension target rather than the containing app target)

5) Make a call


Its not possible to hit any breakpoints in the extension if running in XCode regardless of which target you execute. NSLog statements can be viewed via XCode's devices, it indicates that the extension is called in step 4) if the above steps are called. I don't know if/when its called subsequently after that, it has to be otherwise how can an updated list be applied?


If you want to make a change to the label, the OS does caching, so turn off the extension, delete the containing app app, clear the call history from the phone app, install and run again.

Alas, I've just got out of that session and this stuff wasn't spoken about, not even briefly

The CallDirectoryHandler-CXCallDirectoryProvider is a place to refresh a dictionary in memory - CXCallDirectoryExtensionContext.


---> Call this to reload that dictionary whenever you want to push an update.

[CXCallDirectoryManager sharedInstance] reloadExtensionWithIdentifier


It's possible to trigger break point for the context extension in beginRequestWithExtensionContext

1. Debug --> Attach the extension process --> call reloadExtensionWithIdentifier


It's not possible to trigger break point in receivng a call. So i think it is impossible to know whenever a number is hit or not in your provider list programmatically.


It would be nice if a CallHit callback is provided when a call hit the blocked list, so that statistics could be gathered and indicate that is still a alive spam number. But for the privacy point of view, I guess apple won't do it.

Yes, I am. I've told the app to label it "Testcall" which was displayed. And it was labelled as "MyApp Caller-ID: Testcall".

in step 4), I can't see my testApp in the list of "call blocking & identification". Do you konw why?😟