I would like to block calls from specific countries that are upsetting me by calling eight times a day. I would like to create an app that allows to block any numbers with a specific extension (for example +33 France, +212 Maroc, +973 Bahrain, etc...).
I added CallKit, I followed a tutorial with no success. I tried this, but it seems that I can't even block a simple number...
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...
}
Any ideas ?
You have to give country code & contact in addBlockingPhoneNumbers & addIdentificationPhoneNumbers and it will block the incoming calls :