6

How to get the incoming call phone number programmatically by using call kit framework. i tried with cxcallobserver class but no use.

Any suggestions most helpful...

Ashok Narvaneni
  • 196
  • 1
  • 2
  • 8

2 Answers2

10

When using CallKit's Call Blocking & Identification feature (new in iOS 10), phone numbers to be blocked or identified are loaded by your app's Call Directory extension prior to an incoming call and the phone numbers are stored by the system. Then, when an incoming call arrives, this stored data is consulted by the system and an incoming call may either be blocked or identified in the incoming call UI with the label provided.

For privacy and performance reasons, Call Directory app extensions are not launched when incoming calls arrive and an app extension cannot retrieve the phone number for an incoming call.

Stuart M
  • 11,458
  • 6
  • 45
  • 59
  • 4
    If this is true, then it is practically useless as caller ID. An app cannot know in advance who is going to call! It has to be runtime. – Sarang Jul 08 '16 at 20:08
  • 3
    How truecaller find the incoming call? – Saurabh Jain Nov 29 '16 at 05:18
  • please check the link http://stackoverflow.com/questions/40837561/how-to-use-call-directory-extension-to-identify-a-incoming-call-in-my-applicatio – Saurabh Jain Nov 29 '16 at 06:35
  • @Stuart M : can you help me : http://stackoverflow.com/questions/41845576/ios-10-how-to-show-incoming-voip-call-notification-when-app-is-in-background – Abhishek Thapliyal Jan 31 '17 at 14:30
0

The Call Directory extension introduced in iOS 10 works like the Safari Content Blocker Extension that was introduced in iOS 9. Your extension has to supply a list of phone numbers (in safari's extension, it was a json file), these numbers will be stored by the iOS, and on the event of an incoming call, the system checks the list provided by your extension( same like safari would check the rules specified by the json file before loading a website ), provided, your extension is active at that time.

So, using this feature for creating a Caller ID like app is not possible, because things are not dynamic. Also there may be a limit on the number of phone numbers you can provide in the list, which hopefully be announced by the iOS 10 release.

Sagar D
  • 2,588
  • 1
  • 18
  • 31
  • Do have the code which I can use.. or any reference where I can find some code on this! – Nithin Pai Sep 23 '16 at 16:59
  • Any word on the limit of numbers? Also, do you know when and how often your extension is run to add new numbers? What about removing previously added numbers? – Chris Wagner Dec 10 '16 at 04:48
  • 1
    @ChrisWagner As of now, nothing about the limit has been stated on the Developer website. For removing numbers, I’ve retrieved all the numbers in a data structure, removed the number and then saved all the numbers again. The frequency of the update also depends on iOS, however, you can force update by using : [[CXCallDirectoryManager sharedInstance] reloadExtensionWithIdentifier:EXTENSION_IDENTIFIER completionHandler:^(NSError * _Nullable error) { //your completetion }]; – Sagar D Dec 30 '16 at 09:46
  • Thanks @ShaggyD, I was able to index upwards of 6,700 records without issue. I can also confirm that the reload works and is a wholesale operation, any previous indexed items will be removed upon the reload. Which makes sense as you need to provide the numbers in sequential order. – Chris Wagner Dec 30 '16 at 19:46
  • After some experimentation, I've found that the maximum number of blocked call entries is somewhere around 2,000,000. It's hard to say if this is per app, or a total for all call blocking apps loaded on the phone. – Alan Kinnaman May 27 '17 at 07:52