Manage Rulesets
Provides control over which sets of advertising, tracker and social media blocking rules are active.
List the Available Rulesets
const rulesets: Rulesets[] = await client.listRulesets()do {
let rulesets = try await client.listRulesets()
} catch {
// Handle failure
}// val client: SudoAdTrackerBlockerClient
launch {
try {
val rulesets = withContext(Dispatchers.IO) {
client.listRulesets()
}
// Find the advertising blocking ruleset
val adBlockRuleset = rulesets.find { ruleset ->
ruleset.type == Ruleset.Type.AD_BLOCKING
}
} catch (e: SudoAdTrackerBlockerException) {
// Handle/notify user of exception
}
}Update Rulesets
/*
* The `updateRulesets` method returns a promise that
* resolves when rulesets have been updated.
*
* The rulesets are cached via the StorageProvider
* provided to the client.
*/
await client.updateRulesets()// val client: SudoAdTrackerBlockerClient
launch {
try {
withContext(Dispatchers.IO) {
// For example, if only interested in ads and privacy blocking
client.updateRulesets(
Ruleset.Type.AD_BLOCKING,
Ruleset.Type.PRIVACY
)
}
} catch (e: SudoAdTrackerBlockerException) {
// Handle/notify user of exception
}
}Getting the Active Rulesets
Setting the Active Rulesets
Last updated