5

I am trying to integrate CallDirectory Extension for blocking some incoming call. But application is not even recognising the numbers provided for blocking. Is there anyone who have succeeded in doing this ?? You can see the format that i have used..

   private func addIdentificationPhoneNumbers(to context: CXCallDirectoryExtensionContext) throws {

            let phoneNumbers: [CXCallDirectoryPhoneNumber] = [ 18775555555, 18885555555,+91949520]
            let labels = [ "Telemarketer", "Local business","myPhone"]

            for (phoneNumber, label) in zip(phoneNumbers, labels) {
                context.addIdentificationEntry(withNextSequentialPhoneNumber: phoneNumber, label: label)
            }
        }

And , i referred this for development. http://iphoneramble.blogspot.in/2016/07/ios-10-callkit-directory-extension.html

Testing Device & iOS Version - iphone 5s ,iOS 10.1

good4pc
  • 711
  • 4
  • 17

3 Answers3

6

Atlast , I have got the solution for call blocking. I haven't had a way to check if the call blocking code is working or not. Here are some of the things that i have done for making it work.

  • Check if your application is running in 64 bit iOS device (iphone 5s or greater devices)
  • Adding the numbers in numerically ascending order
  • Add country code to every number
  • A sample code for adding mobile numbers for blocking is given below

    let phoneNumber : CXCallDirectoryPhoneNumber = CXCallDirectoryPhoneNumber("+9194******")! context.addBlockingEntry(withNextSequentialPhoneNumber: phoneNumber)

  • Check your application has given permission to black calls (setting -> phone -> call Blocking & identification -> Check your app is allowed to block calls)

  • You can also check the enabledStatus by putting this below code in your viewController

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

  • Also , add following code to viewController

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

You will find these url's helpful for the development. http://iphoneramble.blogspot.in/2016/07/ios-10-callkit-directory-extension.html

https://translate.google.com/translate?hl=en&sl=zh-CN&u=http://colin1994.github.io/2016/06/17/Call-Directory-Extension-Study/&prev=search

Kindly please let me know if you have got improved methods and corrections. Thanks and happy coding.

good4pc
  • 711
  • 4
  • 17
2

Good to see Apple listening to enhancement requests with CX. With iOS 13.4, Apple added the ability to open Call Blocking & Identification settings directly from the app.

func openSettings(completionHandler completion: ((Error?) -> Void)? = nil)

https://developer.apple.com/documentation/callkit/cxcalldirectorymanager/3521394-opensettings

Debaprio B
  • 503
  • 7
  • 9
1

The array of phone numbers must be a sorted list of int64's. From smallest to largest. The list will be rejected with an "entries out of order" error otherwise.

Matt Weinecke
  • 602
  • 6
  • 17