问题
Is it possible to create a whitelist call blocking app in iOS 11?
For example, I want to block all numbers except those in my contacts list.
It looks like the api only allows you to create a list of numbers to block, not a list of numbers to allow.
https://developer.apple.com/documentation/callkit
回答1:
Yes, you can only block specific list, you don't have permission to invert the case. This is against Apple's policy. Not sure if possible by using private apis, otherwise by public/legal way, you cant do that.
This is text from apple's documentation:
When a phone receives an incoming call, the system first consults the user’s block list to determine whether a call should be blocked. If the phone number is not on a user- or system-defined block list, the system then consults your app’s Call Directory extension to find a matching blocked number.
Above text clearly says that, when call received, it only consult your list to check for block list, invert case is not available.
Even you can remove blocked contacts added by other apps, you have only access to blocked numbers added by your app's call directory extension.
So, If you are thinking of blocking all numbers except some list, then this is not possible in iOS.
回答2:
You cannot achieve this with CallKit, however there is one (much more complicated) way to dismiss incoming calls and do exactly what you want with an external Bluetooth device - like this kind of prototyping board (product is no more sold but you will find some other nice boards around the web).
The trick is to pair your App with a Bluetooth device that implements the Apple ANCS profile. This profile will make your device able to answer to incoming notifications and calls... See it coming? You can imagine this like a minimalistic iWatch from where you could answer or reject calls and any notification. If your App is connected and can communicate with the device, then it will be able to send a command asking to dismiss a call for you.
Thus, at the end it would works as is:
- you connect to your paired Bluetooth device,
- when you receive a call it sends you the caller identifier,
- you compare this identifier to your whitelist,
- if not present, you ask your device to answer "no" to the call notification,
- the call is rejected.
Of course that is very far from what you expected when asking this question, but it's worth mentioning it as this is the only doable (and tested!) solution today.
来源:https://stackoverflow.com/questions/47183540/can-callkit-block-all-calls-except-whitelisted-contacts