BannerAdHandler

actual class BannerAdHandler(activity: Any?)
expect class BannerAdHandler(activity: Any?)

A BannerAdHandler is a landscape ad that covers part of the host app screen.

Parameters

activity

Android required Activity

// Instantiate
val ad = BannerAd(activity, size)
// Load the Ad
ad.load(
adUnitId = "AD_UNIT_ID_GOES_HERE", // Banner Ad Unit ID from AdMob
onLoad = {
// ad.setListeners could go here instead
},
onFailure = { } // Callback when ad fails to load
)
// (optional) Observe what happens to the ad after it's shown
ad.setListeners(
onFailure = {}, // Callback when ad fails to display
onDismissed = {}, // Callback when ad is dismissed
onShown = {}, // Callback after ad is shown
onImpression = {}, // Callback after the ad makes an impression
onClick = {} // Callback on ad click
)
// Show the ad
ad.show()

See also

actual class BannerAdHandler(activity: Any?)

Constructors

Link copied to clipboard
actual constructor(activity: Any?)
expect constructor(activity: Any?)
actual constructor(activity: Any?)

Properties

bannerView
Link copied to clipboard
Link copied to clipboard
actual val state: AdState

Determines the AdState of the BannerAdHandler

expect val state: AdState

Determines the AdState of the BannerAdHandler

actual val state: AdState

Determines the AdState of the BannerAdHandler

Functions

Link copied to clipboard
@RequiresPermission(value = "android.permission.INTERNET")
actual fun load(adUnitId: String, adSize: AdSize)
expect fun load(adUnitId: String = AdUnitId.BANNER_DEFAULT, adSize: AdSize = AdSize.FULL_BANNER)

Loads an Banner Ad. Note: Make all calls to the Mobile Ads SDK on the main thread.

actual fun load(adUnitId: String, adSize: AdSize)
Link copied to clipboard
actual fun setListeners(onLoad: () -> Unit, onFailure: (Exception) -> Unit, onDismissed: () -> Unit, onShown: () -> Unit, onImpression: () -> Unit, onClick: () -> Unit)
expect fun setListeners(onLoad: () -> Unit, onFailure: (Exception) -> Unit, onDismissed: () -> Unit, onShown: () -> Unit = {}, onImpression: () -> Unit = {}, onClick: () -> Unit = {})

Sets the callbacks for the Banner Ad.

actual fun setListeners(onLoad: () -> Unit, onFailure: (Exception) -> Unit, onDismissed: () -> Unit, onShown: () -> Unit, onImpression: () -> Unit, onClick: () -> Unit)