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 phone number to the user's block list using HiyaRepo.addToDenyList(String, Long, Boolean)
// Block a specific number
var phoneNumberToBlock = "5555555555"
val countryCallingCode = 1L
var isPartial = false
val hiyaRepo = HiyaService.getHiyaRepo(context)
hiyaRepo.addToDenyList(phoneNumberToBlock, countryCallingCode, isPartial)
// Block numbers that start with a specific prefix
phoneNumberToBlock = "555"
isPartial = true
hiyaRepo.addToDenyList(phoneNumberToBlock, countryCallingCode, isPartial)
Blocking calls requires the Android call screener role (ROLE_CALL_SCREENING)
Get the current block list
Get the current block list by calling HiyaRepo.getDenyList()
// Get the block list
val hiyaRepo = HiyaService.getHiyaRepo(context)
val blockList: List<DenyNumber> = hiyaRepo.getDenyList()
Blocking calls requires the Android call screener role (ROLE_CALL_SCREENING)
Remove a number from the block list
Remove a phone number from the user's block list using HiyaRepo.removeFromDenyList(Int). This function takes an id which can be obtained from a DenyNumber object returned from HiyaRepo.getDenyList()
// Unblock a specific number
val hiyaRepo = HiyaService.getHiyaRepo(context)
val denyNumberFromList: DenyNumber = hiyaRepo.getDenyList().first()
hiyaRepo.removeFromDenyList(denyNumberFromList.id)
Blocking calls requires the Android call screener role (ROLE_CALL_SCREENING)