How to: Manage Personal Block List
Use the following functions to allow your users to manage their personal block list:
Add a number to the block list
Add a number to the blocklist using Hiya.setBlockStatus(phone: String, blocked isBlocked: Bool, completion: @escaping (PhoneProfile?, String?) -> Void), passing true
for the value of blocked:
let phoneToBlock: String = "+12065551212"
Hiya.setBlockStatus(phone: phoneToBlock, blocked: true) { phoneProfile, error in
if let error {
print("Error adding \(phoneToBlock) to blocklist: \(error.localizedDescription)")
}
}
Get the current block list
A list of all currently blocked numbers can be obtained from the Hiya
class var allBlockedProfiles
.
let userBlocklist = Hiya.allBlockedProfiles
Remove a number from the block list
Remove a number from the blocklist using Hiya.setBlockStatus(phone: String, blocked isBlocked: Bool, completion: @escaping (PhoneProfile?, String?) -> Void), passing false
for the value of blocked:
let phoneToRemove: String = "+12065551212"
Hiya.setBlockStatus(phone: phoneToRemove, blocked: false) { phoneProfile, error in
if let error {
print("Error removing \(phoneToBlock) from blocklist: \(error.localizedDescription)")
}
}