Search code examples
iosswiftcallkit

How to call `beginRequest` of Call Directory Extension?


I have to test about Call Blocking & Identification. So I followed the steps below.

(1) Create a Call Directory Extension in my project from [File] > [New] > [Target].

(2) Add a logging in Call Directory Extension to test.

class CallDirectoryHandler: CXCallDirectoryProvider {
  override func beginRequest(with context: CXCallDirectoryExtensionContext) {
    print("test")
  }
}

(3) Call reload function of CallKit on my project.

CXCallDirectoryManager.sharedInstance.reloadExtension(withIdentifier: "EXTENSION_BUNDLE_IDENTIFIER", completionHandler: { (error) in
  if let error = error {
    print(error.localizedDescription)

  } else {
    print("success")
  }
})

(4) Check my app is enabled in Settings > Phone > Call blocking & identification.

And success of 3 is printed, but test of 2 isn't printed.

Is there anything I should check?

Thanks in advance.


Solution

  • I think it is being called correctly as you can check the response on your app target sandbox.

    The only way I know to get access to the logs in this case is by going in the Devices window of Xcode and looking at the device console, you should be able to see logs like this:

    com.apple.CallKit.CallDirectory: ...

    You might also try to debug it by putting directly a breakpoint in this line:

    print("test")

    Check also tutorials on finding out if you have any issue in the setup between your extension and your app sandboxes, there is a good one here: https://pusher.com/tutorials/callkit-ios-part-1