我在单例中从 CNContact 创建数字数组。但是当我重新加载我的 CallKit 扩展时,CallKit 不会阻止我之前阻止的号码。号码长度为 11 个字符。数组不为空。重新加载 CallKit Extension 后没有错误。
static let shared = BlockNumbersManager()
private init() { }
open var blockNumbers: [CXCallDirectoryPhoneNumber] = []
open func getIntegerBlockNumbers() -> [CXCallDirectoryPhoneNumber] {
return blockNumbers
}
private func addBlockingPhoneNumbers(to context: CXCallDirectoryExtensionContext) throws {
let phoneNumbers: [CXCallDirectoryPhoneNumber] = BlockNumbersManager.shared.getIntegerBlockNumbers() // TODO: add numbers for block dynamically.
for phoneNumber in phoneNumbers {
context.addBlockingEntry(withNextSequentialPhoneNumber: phoneNumber)
}
}
我错过了什么?