Jas_meet
Jas_meet

Reputation: 366

CallKit: Add number to blocking list of CXCallDirectoryProvider

I want to add number to blocking list, while using my application.

Currently, I am trying to update the blocking list, but its not working

 let callDirectoryExtensionContext = CXCallDirectoryExtensionContext.init()
    let phoneNumbers: [CXCallDirectoryPhoneNumber] = [ xx_xxx_xxx_xxxx ]
    for phoneNumber in phoneNumbers {
        callDirectoryExtensionContext.addBlockingEntry(withNextSequentialPhoneNumber: phoneNumber)
    }


    let callDirectoryProvider = CXCallDirectoryProvider.init()
    callDirectoryProvider.beginRequest(with: callDirectoryExtensionContext)

    CXCallDirectoryManager.sharedInstance.reloadExtension(withIdentifier: "com.xxxxxxx.xxxxx.CustomCallDirectoryProvider") { (error) in
        if let error = error {
            print(error.localizedDescription)
        }
    }

Is it possible with CallKit, to update or add numbers to blocking list.

Upvotes: 0

Views: 1127

Answers (1)

Matt Weinecke
Matt Weinecke

Reputation: 602

You can't make those types of calls arbitrarily in your app. You must do it by creating an extension target in Xcode, implementing the CXCallDirectoryProvider protocol, and implementing the beginRequest callback. This is then called when iOS determines your extension needs to be loaded or reloaded.

You will want to read Apple's App Extension guide.

Upvotes: 1

Related Questions