StorytellerAdMobModule

@Singleton
class StorytellerAdMobModule @Inject constructor(applicationContext: Context) : StorytellerModule

The Storyteller AdMob Module is responsible for integrating AdMob ads into the Storyteller SDK. It allows for fetching and displaying ads from AdMob within Storyteller Stories and Clips.

Important: Only one ad module should be used at a time. Do not use StorytellerAdMobModule together with StorytellerGamModule. The SDK behavior is undefined when both modules are registered.

To use this module, first obtain an instance using StorytellerAdMobModule.getInstance. Then, initialize it by calling the init method:

val adMobModule = StorytellerAdMobModule.getInstance(applicationContext).apply {
init(
adUnit = { adRequestInfo ->
when (adRequestInfo) {
is StorytellerAdRequestInfo.StoriesAdRequestInfo -> "ca-app-pub-xxx/stories"
else -> "ca-app-pub-xxx/clips"
}
}
)
}
Storyteller.modules = listOf(adMobModule)

Key Differences from StorytellerGamModule

  • No custom native templates: AdMob does not support custom native ad templates

  • No key-value pair targeting: AdMob does not support direct KVP targeting like GAM

  • Separate loading paths: Native ads use AdLoader, banner ads use standalone AdView

Test Ad Unit IDs

For development and testing, use Google's official test ad unit IDs:

  • Native Advanced: ca-app-pub-3940256099942544/2247696110

  • Banner: ca-app-pub-3940256099942544/6300978111

For more information on integrating ads, see the Storyteller Ads Documentation.

Parameters

applicationContext

The application context.

See also

StorytellerModule
StorytellerAdRequestInfo

Constructors

Link copied to clipboard
@Inject
constructor(applicationContext: Context)

Creates a new instance of StorytellerAdMobModule. This is typically handled by Dagger.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
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.