Search…
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.
TypeScript
Swift
Kotlin
1
import { FilterException } from '@sudoplatform/sudo-ad-tracker-blocker'
2
3
const exceptions: FilterException[] = await client.getExceptions()
Copied!
1
let client: SudoAdTrackerBlockerClient!
2
let exceptions = client.getExceptions()
Copied!
1
// val client: SudoAdTrackerBlockerClient
2
3
launch {
4
try {
5
val isMySiteExcepted = withContext(Dispatchers.IO) {
6
client.getExceptions().firstOrNull { exc ->
7
exc.source.contains("http://myfavourite.domain.eu")
8
}
9
} ?: false
10
} catch (e: SudoAdTrackerBlockerException) {
11
// Handle/notify user of exception
12
}
13
}
Copied!

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.
TypeScript
Swift
Kotlin
1
import { FilterException } from '@sudoplatform/sudo-ad-tracker-blocker'
2
3
const hostException: FilterException = {
4
// `type` === 'host' prevents blocking on
5
// any pages at `example.com`.
6
type: 'host',
7
source: 'http://example.com/page.html'
8
}
9
10
const pageException: FilterException = {
11
// `type` === 'page' prevents blocking on
12
// only `example.com/page.html`.
13
type: 'page',
14
source: 'https://example.com/page.html'
15
}
16
17
// Add both exceptions to the exceptions list
18
await client.addExceptions([
19
hostException,
20
pageException
21
])
Copied!
1
let client: SudoAdTrackerBlockerClient!
2
client.addExceptions([BlockingException("example.com")])
Copied!
1
// val client: SudoAdTrackerBlockerClient
2
3
launch {
4
try {
5
withContext(Dispatchers.IO) {
6
client.addExceptions(
7
toHostException("http://somehost.com"),
8
toPageException("http://myfavourite.domain.eu/homepage")
9
)
10
}
11
} catch (e: SudoAdTrackerBlockerException) {
12
// Handle/notify user of exception
13
}
14
}
Copied!

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.
TypeScript
Swift
Kotlin
1
const exception: FilterException = {
2
type: 'host',
3
source: 'http://example.com/page.html'
4
}
5
6
/*
7
* The `removeExceptions` method returns a Promise that will
8
* resolve when the exception has been removed from the
9
* storage provider provided to the client.
10
*
11
* In this case the removed exception will be for all pages
12
* of `example.com` since the exception is of type `host`.
13
*/
14
15
await client.removeExceptions([exception])
Copied!
1
let client: SudoAdTrackerBlockerClient!
2
client.removeExceptions([BlockingException("example.com")])
Copied!
1
// val client: SudoAdTrackerBlockerClient
2
3
launch {
4
try {
5
withContext(Dispatchers.IO) {
6
client.removeExceptions(
7
toHostException("http://somehost.com"),
8
toPageException("http://myfavourite.domain.eu/homepage")
9
)
10
}
11
} catch (e: SudoAdTrackerBlockerException) {
12
// Handle/notify user of exception
13
}
14
}
Copied!

Removing all the Entries from the Exceptions List

To remove all entries from the list of exceptions you can use the removeAllExceptions method.
TypeScript
Swift
Kotlin
1
/*
2
* The `removeAllExceptions` method returns a Promise that
3
* will resolve when the all of the exceptions have succesfully
4
* been removed from the client's storage provider.
5
*/
6
7
await client.removeAllExceptions()
Copied!
1
let client: SudoAdTrackerBlockerClient!
2
client.removeAllExceptions()
Copied!
1
// val client: SudoAdTrackerBlockerClient
2
3
launch {
4
try {
5
withContext(Dispatchers.IO) {
6
client.removeAllExceptions()
7
}
8
} catch (e: SudoAdTrackerBlockerException) {
9
// Handle/notify user of exception
10
}
11
}
Copied!
Last modified 1mo ago