configure

abstract suspend fun configure(networkId: String, parentCoroutineScope: CoroutineScope, configurationTimeout: UInt = DEFAULT_CONFIGURATION_TIMEOUT_SECONDS, cacheSize: UShort = DEFAULT_CACHE_SIZE_MB, globalParameters: GlobalParameters = GlobalParameters(), adRequestGlobalParameters: AdRequestGlobalParameters = AdRequestGlobalParameters()): AdResult<Unit>

Create and configure AdService with the passed parameters.

This method is the only correct way to create an AdService. It configure the AdService, sets global parameters, loads the initial cookies that will be used by the ad server to identify the user, and registers all standard renderers.

Note: If you want to prevent user tracking, you can use GlobalParameters.gdpr, GlobalParameters.isOptOutEnabled, or GlobalParameters.accessMode when passing the globalParameters. At the same time, if the app uses a CMP that follows TCF v2 format, GlobalParameters.gdpr can be set automatically.

Return

The result of the AdService configuration.

Parameters

networkId

The unique identifier of the ad network.

parentCoroutineScope

The CoroutineScope that defines the lifetime of AdService. All internal operations will be cancelled when this scope is cancelled. Typically, this should be a lifecycle-aware scope like viewModelScope, lifecycleScope, or a custom scope that's cancelled when the owner is destroyed.

configurationTimeout

Timeout for the cookie loading, in seconds. 10 seconds by default.

cacheSize

Cache size in MB. 100 MB by default.

globalParameters

Common GlobalParameters that will be used each time you create an AdRequest, TagRequest, and TrackingRequest. You can change them over time using AdService.setGlobalParameters and AdService.removeGlobalParameter.

adRequestGlobalParameters

AdRequestGlobalParameters that will be used each time you create an AdRequest. You can change them over time using AdService.setAdRequestGlobalParameters and AdService.removeAdRequestGlobalParameter.