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
To do that, go to the “Recents” tab in the Phone app and tap the “i” icon next to the phone number or the person's name. From the bottom here, tap the “Block this caller” button. Then select “Block Contact” to confirm.
Restart your device. Then proceed to iPhone Settings > Phone > Call Blocking & Identification > Turn ON Productive.
Go to Settings > Phone. Tap Call Blocking & Identification. Under Allow These Apps To Block Calls And Provide Caller ID, turn the app on or off.
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.
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)
CXCallDirectoryManager.sharedInstance.getEnabledStatusForExtension(withIdentifier: "bundleIdentifierOfYourExtension", completionHandler: {(status, error) -> Void in if let error = error { print(error.localizedDescription) } })
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.
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