26 Replies
      Latest reply on Aug 15, 2017 4:31 AM by ryan2clw
      klimchuk Level 1 Level 1 (0 points)

        I've tried to attach to Phone process (and many others) but incoming call is not hitting breakpoint in CXCallDirectoryProvider.beginRequest

        Considering lack of documentation what am I doing wrong?

        Thanks in advance!

        • Re: How to debug Call Directory Extension?
          svarrall Level 2 Level 2 (30 points)

          Have you found ANY documentation? I can barely it mentioned anywhere.

          • Re: How to debug Call Directory Extension?
            yanniks Level 1 Level 1 (0 points)

            CXCallDirectoryProvider seems to be broken in the first beta.

            Calling

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

            outputs

            sqlite3_prepare_v2 for query 'INSERT OR IGNORE INTO PhoneNumber (number) VALUES ' returned 1 errorMessage 'near " ": syntax error'
            

            for me.

             

            So let's wait for beta 2.

            • Re: How to debug Call Directory Extension?
              mungbeans Level 1 Level 1 (10 points)

              I've managed to get this working, here's what I did and some observations:

               

              1) Create a new target of Type Call Directory Extension.

              2) Edit retrievePhoneNumbersToIdentifyAndLabels() to include the number and label you want. Add +CountryCode at the start (not confirmed yet if this is essential)

              3) Run the containing app target.

              4) In setting go to Phone/Call Blocking & IdentificationAnd turn on you extension (or it will automatically be turned on if you run the entension target rather than the containing app target)

              5) Make a call

               

              Its not possible to hit any breakpoints in the extension if running in XCode regardless of which target you execute. NSLog statements can be viewed via XCode's devices, it indicates that the extension is called in step 4) if the above steps are called. I don't know if/when its called subsequently after that, it has to be otherwise how can an updated list be applied?

               

              If you want to make a change to the label, the OS does caching, so turn off the extension, delete the containing app app, clear the call history from the phone app, install and run again.

                • Re: How to debug Call Directory Extension?
                  royycc Level 1 Level 1 (0 points)

                  The CallDirectoryHandler-CXCallDirectoryProvider is a place to refresh a dictionary in memory - CXCallDirectoryExtensionContext.

                   

                  ---> Call this to reload that dictionary whenever you want to push an update.

                  [CXCallDirectoryManager sharedInstance] reloadExtensionWithIdentifier

                   

                  It's possible to trigger break point for the context extension in beginRequestWithExtensionContext

                  1. Debug --> Attach the extension process --> call reloadExtensionWithIdentifier

                   

                  It's not possible to trigger break point in receivng a call. So i think it is impossible to know whenever a number is hit or not in your provider list programmatically.

                   

                  It would be nice if a CallHit callback is provided when a call hit the blocked list, so that statistics could be gathered and indicate that is still a alive spam number. But for the privacy point of view, I guess apple won't do it.

                    • Re: How to debug Call Directory Extension?
                      mungbeans Level 1 Level 1 (10 points)

                      royycc, is that some documentation you are quoting from in the first couple of paragraphs? If so where is it? (I couldn't find that in the Apple API reference documentation for this stuff).

                      • Re: How to debug Call Directory Extension?
                        mungbeans Level 1 Level 1 (10 points)

                        >> "It would be nice if a CallHit callback is provided when a call hit the blocked list"

                         

                        Does that mean you have been able to get call blocking to work? I'm able to get call identification to work but not call blocking.

                         

                        If I add a number to block like this:

                         

                            private func retrievePhoneNumbersToBlock() -> [String]? {
                                  return ["+12067958411"]
                            }
                        
                        

                        Then make a call from the number, then there's no difference - the incoming call still displays just as usual. (I've ensured the number is being added by the extension without a problem by calling reloadExtensionWithIdentifier)

                         

                        Is there anything else you did to get call blocking to work?

                          • Re: How to debug Call Directory Extension?
                            royycc Level 1 Level 1 (0 points)

                            Look at the API of all the CXCallDirectory  ( justa 5 available api .... ), then you would understand how it works.

                            https://developer.apple.com/library/prerelease/content/releasenotes/General/iOS10APIDiffs/Swift/CallKit.html

                             

                            I tried both call blocking and identification successfully.

                             

                            - In blocking, you would not notice anything on the phone, that number just cant' call in.

                            - For call identifcation, it display the text   「APPNAME」Caller ID : LABEL

                             

                            If you made identifcation working, the number should be correct. May be try adding a breakpoint to ensure the code execute as you expect.

                            • Re: How to debug Call Directory Extension?
                              MattTW Level 1 Level 1 (0 points)

                              Ditto.   I am able to successfully provide a caller ID, and I added an NSLog that is showing that the code that adds the blocked number is running with seemingly no error, however the number is not blocked.   I've tried lots of variations on the phone number string, including +(country code)(phone number).

                               

                              Is there something displayed to the console by iOS when a phone number is blocked or being checked if it should be blocked?

                               

                              I am seeing reports of it working for folks in countries other than the USA, so I wonder if that is somehow a factor.

                                • Re: How to debug Call Directory Extension?
                                  MattTW Level 1 Level 1 (0 points)

                                  This is definitely a caching issue on the iOS 10 beta 1 side.    I restored my phone and installed the app, and it blocked the number I specified.

                                    • Re: How to debug Call Directory Extension?
                                      Dragna Level 1 Level 1 (0 points)

                                      Were you able to find a way to make it work every time ?

                                      I have no problems making the "Identification" work, but the blocking part is not working for me.

                                       

                                      When looking at the logs from my device, I can see an entry saying :

                                      com.apple.CallKit.CallDirectory[251] <Notice>: Added 1 phone number blocking entries
                                      com.apple.CallKit.CallDirectory[251] <Notice>: Data request completed successfully
                                      

                                       

                                      But I am still able to call myself :/ (I'm on the iOS10 second public beta)

                                       

                                      By the way, for the persons that are looking for the NSLog, the only way I found to get access to them is by going into the "Devices" window of Xcode and looking at the device console.

                                • Re: How to debug Call Directory Extension?
                                  kane.codes Level 1 Level 1 (10 points)

                                  Seconded, where's this documentation coming from?

                                • Re: How to debug Call Directory Extension?
                                  Colin1994 Level 1 Level 1 (0 points)

                                  in step 4), I can't see my testApp in the list of "call blocking & identification".  Do you konw why?

                                    • Re: How to debug Call Directory Extension?
                                      mungbeans Level 1 Level 1 (10 points)

                                      No idea, I've not experienced any problems with it not appearing. Have you just tried creating a basic template extension (create a new project of type application, then create a new target of type call directory extension, and make sure the developer team is set to the same for each). Then run the containing app scheme or etension scheme the via xcode and it should appear

                                  • Re: How to debug Call Directory Extension?
                                    sundeep_IOS Level 1 Level 1 (0 points)

                                    i have a scenario like fetching the contacts from contacts framework and picking the selected contacts from the contacts framework and passing the selected list of contacts(array) to CALLKIT.

                                    Once i get a call from any of the selected(which i picked earlier from contacts framework and passed it to call kit extension)...my bluetooth device has to vibrate(generally notifying the user)

                                    i would like to know...whether we can pass array(selected contacts) to call kit extension and get notified if we get a call from the array(selected contacts) which we passed to call kit extension method

                                    • (BOOL)addIdentificationPhoneNumbersToContext:(CXCallDirectoryExtensionContext *)context;
                                    • Re: How to debug Call Directory Extension?
                                      ryan2clw Level 1 Level 1 (0 points)

                                      Try debugging the enabled status:

                                      `

                                      var callDirManager = CXCallDirectoryManager.sharedInstance

                                              callDirManager.getEnabledStatusForExtension(withIdentifier: "com.dimez.CallBlock.CallDirectoryBlockage") { (cXCallDirectoryManagerEnabledStatus) in

                                                  print("Enabled status of extension: \(cXCallDirectoryManagerEnabledStatus.0)")

                                                  print("Possible error: \(String(describing: cXCallDirectoryManagerEnabledStatus.1))")

                                              }

                                      extension CXCallDirectoryManager.EnabledStatus: CustomStringConvertible {

                                       

                                          public var description: String {

                                              switch self{

                                              case .disabled:

                                                  return "disabled"

                                              case .enabled:

                                                  return "enabled"

                                              case .unknown:

                                                  return "unknown"

                                              }

                                          }

                                      }

                                      `

                                      Shouldn't say this:

                                      Enabled status of extension: disabled