Call blocking feature in iOS 10
Asked Answered
T

3

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

Topple answered 18/11, 2016 at 9:50 Comment(1)
Please share some code.Dud
T
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.

Topple answered 21/11, 2016 at 10:53 Comment(5)
Numerically ascending order in the sense?Stephanstephana
Call directory extension not give any identification for a numberStephanstephana
also not block the call help meStephanstephana
first of all , you are not able to receive phone number from incoming call using call kit.Topple
check whether call blocking feature is switched on in setting -> phone -> call Blocking & identification -> Check your app is allowed to block callsTopple
L
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

Landsman answered 13/5, 2020 at 16:40 Comment(0)
T
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.

Thibault answered 20/11, 2016 at 12:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.