在 iOS 中,有没有办法使用呼叫目录扩展来阻止无来电显示?

Is there a way to block No Caller ID with Call Directory Extension in iOS?

我正在为 iOS 开发自定义 Phone 拨号器应用程序。我的想法是通过使用 Call Directory Extension 阻止 No Caller ID phone 呼叫来创造良好的体验。目前 iOS 无法阻止未知来电者,除非打开“请勿打扰”模式。

有没有办法以某种方式以编程方式识别并阻止没有 phone 号码标识的来电者,或者通过阻止显示无来电显示的标签?

到目前为止,我已经在 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)
}

到目前为止,我已经能够阻止这个常规的 phone 号码 38161XXXXXXX,但是,如果同一号码通过隐藏前缀 #31# 来电,呼叫将会接通。

有谁知道这是否可行,有没有办法识别和阻止 No Caller ID?

否,CallKit 呼叫阻止分机必须指定要阻止的号码。您不能指定 "no number" 被阻止。