init

fun init(nativeAdUnit: (StorytellerAdRequestInfo) -> String, bannerAdUnit: (StorytellerAdRequestInfo) -> String?? = null, bottomBannerAdUnit: (StorytellerAdRequestInfo) -> String?? = null, enableBannerAdPriority: Boolean = false, keyValuePairs: () -> Map<String, String> = { emptyMap() })

Initializes the Storyteller AdMob module with the necessary configuration for ad requests.

Parameters

nativeAdUnit

A lambda function that accepts a StorytellerAdRequestInfo object and returns the appropriate ad unit ID (String) for native ads. This is the primary ad type. AdMob ad unit IDs have the format ca-app-pub-xxx/yyy. Example: ``kotlin adUnit = { adRequestInfo -> when (adRequestInfo) { is StorytellerAdRequestInfo.StoriesAdRequestInfo -> "ca-app-pub-xxx/stories" else -> "ca-app-pub-xxx/clips" } } ``

bannerAdUnit

An optional lambda function for banner ads used as fallback when native ads fail to load (e.g., no fill). If not provided, no fallback will occur and the native ad error will be returned directly. Example: { adRequestInfo -> "ca-app-pub-xxx/banner_fallback" }

bottomBannerAdUnit

An optional lambda function for bottom banner ads in clips. If not provided, bottom banner ads will not be requested. Only 300x50 and 320x50 ad sizes are supported. Example: { adRequestInfo -> "ca-app-pub-xxx/bottom_banner" }

enableBannerAdPriority

When true, banner ads are attempted first with native ads as fallback on failure. When false (default), native ads are attempted first with banner ads as fallback. This parameter only takes effect if bannerAdUnit is also provided; otherwise, only native ads will be requested regardless of this setting.

keyValuePairs

A lambda function that returns a Map of String to String. These are custom key-value pairs that will be passed to AdMob as network extras for ad targeting. If Storyteller.eventTrackingOptions.enableAdTracking is disabled, these pairs will not be sent. Example: { mapOf("customKey" to "customValue") }