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()

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.

const exception: FilterException = {
  type: 'host',
  source: 'http://example.com/page.html'
}

/*
 * The `removeExceptions` method returns a Promise that will
 * resolve when the exception has been removed from the 
 * storage provider provided to the client.
 *
 * In this case the removed exception will be for all pages 
 * of `example.com` since the exception is of type `host`.
 */

await client.removeExceptions([exception])

Removing all the Entries from the Exceptions List

To remove all entries from the list of exceptions you can use the removeAllExceptions method.

/*
 * The `removeAllExceptions` method returns a Promise that 
 * will resolve when the all of the exceptions have succesfully
 * been removed from the client's storage provider.
 */

await client.removeAllExceptions()

Last updated