在iOS中,是否可以使用Call Directory Extension来阻止No Caller ID?

时间:2018-08-08 07:29:55

标签: ios swift block callkit caller-id

我正在为iOS使用自定义电话拨号器应用程序。我的想法是通过能够使用“呼叫目录扩展”阻止“任何呼叫者ID”的电话来创建良好的体验。当前在iOS上,除了打开“请勿打扰”模式外,无法阻止未知的呼叫者。

是否有办法以编程方式识别和阻止没有电话号码标识的呼叫者,或者通过阻止显示“没有呼叫者ID”的标签?

到目前为止,我已经在CallDirectoryHandler

中进行了尝试
private func addAllBlockingPhoneNumbers(to context: CXCallDirectoryExtensionContext) {

    /**
     Retrieve all phone numbers to block from data store. For optimal performance and memory usage
     when there are many phone numbers, consider only loading a subset of numbers at a given time
     and using autorelease pool(s) to release objects allocated during each batch of numbers
     which are loaded.

     Numbers must be provided in numerically ascending order.
    */
    let unknownCaller = CXCallDirectoryPhoneNumber()
    let unknownCaller1: CXCallDirectoryPhoneNumber = 0
    let unknownCaller2: CXCallDirectoryPhoneNumber = 00000000
    let caller381X: CXCallDirectoryPhoneNumber = 38161XXXXXXX

    context.addBlockingEntry(withNextSequentialPhoneNumber: unknownCaller)
    context.addBlockingEntry(withNextSequentialPhoneNumber: unknownCaller1)
    context.addBlockingEntry(withNextSequentialPhoneNumber: unknownCaller2)
    context.addBlockingEntry(withNextSequentialPhoneNumber: caller38161X)
}

到目前为止,我已经可以阻止此常规电话号码38161XXXXXXX,但是,如果通过隐藏#31#前缀来拨打相同的电话号码,则该呼叫将通过。

有人知道这是否可行,是否有办法识别和阻止“无来电显示”?

1 个答案:

答案 0 :(得分:3)

否,CallKit呼叫阻止分机必须指定要阻止的号码。您不能指定要阻止的“无号码”。