I am using callkit to identify phone number.
It gives me error : The operation couldn’t be completed. (com.apple.CallKit.error.calldirectorymanager error 1.)
override func viewDidLoad() {
super.viewDidLoad()
let numbers = ["94XXXXXXX"]
let labels = ["TestUser"]
writeFileForCallDirectory(numbers: numbers, labels: labels)
// Do any additional setup after loading the view, typically from a nib.
}
fileprivate func writeFileForCallDirectory(numbers: [String], labels: [String]) {
guard let fileUrl = FileManager.default
.containerURL(forSecurityApplicationGroupIdentifier: "group.com.CallKit.CallBlock")?
.appendingPathComponent("contacts") else { return }
var string = ""
for (number, label) in zip(numbers, labels) {
string += "\(number),\(label)\n"
}
try? string.write(to: fileUrl, atomically: true, encoding: .utf8)
//CXCallDirectoryManager.sharedInstance.reloadExtension(withIdentifier: "group.com.CallKit.CallBlock")
CXCallDirectoryManager.sharedInstance.reloadExtension(withIdentifier: "group.com.CallKit.CallBlock", completionHandler: { (error) -> Void in
if let error = error {
print(error.localizedDescription)
}
})
}
App group is enable to share data between app and extension but I don't know what I am doing wrong.
You are using app group for the reloadExtension.
Use your bundle identifier of your callkit extension.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With