Manage Exceptions
Provides control over which URLs are given an exception from being blocked.
You can control which URLs are permitted to bypass the blocking rules by granting an exception for a specific web page, or an entire host. However, on iOS, exceptions may only be applied to an entire host.
Get the Exceptions List
To get the list of exceptions you can use the getExceptions method.
import { FilterException } from '@sudoplatform/sudo-ad-tracker-blocker'
const exceptions: FilterException[] = await client.getExceptions()let client: SudoAdTrackerBlockerClient!
let exceptions = await client.getExceptions()// val client: SudoAdTrackerBlockerClient
launch {
try {
val isMySiteExcepted = withContext(Dispatchers.IO) {
client.getExceptions().firstOrNull { exc ->
exc.source.contains("http://myfavourite.domain.eu")
}
} ?: false
} catch (e: SudoAdTrackerBlockerException) {
// Handle/notify user of exception
}
}Add to the Exceptions List
To add to the list of exceptions you can use the addExceptions method. You can add the URL of a single page or an entire host to the list of exceptions.
On iOS, exceptions may only apply to an entire host.
import { FilterException } from '@sudoplatform/sudo-ad-tracker-blocker'
const hostException: FilterException = {
// `type` === 'host' prevents blocking on
// any pages at `example.com`.
type: 'host',
source: 'http://example.com/page.html'
}
const pageException: FilterException = {
// `type` === 'page' prevents blocking on
// only `example.com/page.html`.
type: 'page',
source: 'https://example.com/page.html'
}
// Add both exceptions to the exceptions list
await client.addExceptions([
hostException,
pageException
])Remove from the Exceptions List
To remove from the list of exceptions you can use the removeExceptions method. You should supply the same exception value(s) you used when you added the page or host to the list of exceptions.
Removing all the Entries from the Exceptions List
To remove all entries from the list of exceptions you can use the removeAllExceptions method.
Last updated