我想通过每天拨打八次电话来阻止来自特定国家的电话,这些电话让我感到不安。我想创建一个允许使用特定扩展名(例如 +33 France、+212 Maroc、+973 Bahrain 等)阻止任何号码的应用程序。
我添加了 CallKit,我按照教程没有成功。我试过这个,但似乎我什至无法阻止一个简单的号码......
private func addAllBlockingPhoneNumbers(to context: CXCallDirectoryExtensionContext) {
print("1234")
let phoneNumbers: [CXCallDirectoryPhoneNumber] = [ 1234 ]
for phoneNumber in phoneNumbers {
context.addBlockingEntry(withNextSequentialPhoneNumber: phoneNumber)
}
}
private func addOrRemoveIncrementalBlockingPhoneNumbers(to context: CXCallDirectoryExtensionContext) {
print("1234")
// Retrieve any changes to the set of 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.
let phoneNumbersToAdd: [CXCallDirectoryPhoneNumber] = [ 1234 ]
for phoneNumber in phoneNumbersToAdd {
context.addBlockingEntry(withNextSequentialPhoneNumber: phoneNumber)
}
let phoneNumbersToRemove: [CXCallDirectoryPhoneNumber] = [ 1234 ]
for phoneNumber in phoneNumbersToRemove {
context.removeBlockingEntry(withPhoneNumber: phoneNumber)
}
// Record the most-recently loaded set of blocking entries in data store for the next incremental load...
}
有任何想法吗 ?