Bidapp Ads
  • 🎁Ab_dout
  • Integration
    • iOS
      • Getting started
      • Additional Settings
      • App Policy Settings
      • Serverless Settings
      • Interstitial Ads
      • Rewarded Ads
      • Banner Ads
      • SKAdNetwork
      • SwiftUI
    • Android
      • Getting started
      • Additional Settings
      • App Policy Settings
      • Serverless Settings
      • Interstitial Ads
      • Rewarded Ads
      • Banner Ads
      • Jetpack Compose
  • PLUGINS
    • Kotlin Multiplatform
      • Getting started
      • Android Platform Setup
      • iOS Platfrom Setup
      • App Policy Settings
      • Interstitial Ads
      • Rewarded Ads
      • Banner Ads
    • Unreal Engine
      • Getting started
      • App Policy Settings
      • Interstitial Ads
      • Rewarded Ads
      • Banner Ads
      • MREC
    • Unity
      • Getting started
      • Android
      • iOS
      • App Policy Settings
      • Interstitial Ads
      • Rewarded Ads
      • Banner Ads
Powered by GitBook
On this page
  • Stopping and Starting Auto-Refresh
  • Destroying Banners

Was this helpful?

  1. PLUGINS
  2. Kotlin Multiplatform

Banner Ads

To load a banner, create a BannerView and add it as a subview of your view hierarchy.

You can create banners of either 320x50, 300x250 or 728x90 size:


fun createBanner_320x50(activity : Any?) {
    banner = BIDBanner(activity, BIDAdFormat.banner_320x50)
    banner.setBannerViewDelegate(bannerShowDelegate)
}

fun createBanner_300x250(activity : Any?) {
    banner = BIDBanner(activity, BIDAdFormat.banner_300x250)
    banner.setBannerViewDelegate(bannerShowDelegate)
}

fun createBanner_728x90(activity : Any?) {
    banner = BIDBanner(activity, BIDAdFormat.banner_728x90)
    banner.setBannerViewDelegate(bannerShowDelegate)
}

Implement BIDBannerShow so that you are notified of when your ad is ready and of other ad-related events.

//BIDBannerShow protocol methods 

var bannerShow: BIDBannerShow? = object : BIDBannerShow {
    override fun load(info: BIDAdInfo, adView: BIDBanner) {
        print("Banner - adViewDidLoadAd. AdView: $adView, AdInfo: $info")
    }

    override fun display(info: BIDAdInfo, adView: BIDBanner) {
        print("Banner - didDisplayAd. AdView: $adView, AdInfo: $info")
    }

    override fun failToDisplay(info: BIDAdInfo, adView: BIDBanner, error: String) {
        print("Banner - didFailToDisplayAd. AdView: $adView, Error:$errors")
    }

    override fun click(info: BIDAdInfo, adView: BIDBanner) {
        print("Banner - didClicked. AdView: $adView, AdInfo: $info")
    }

    override fun allNetworksFailedToDisplay(error: String) {
        print("Banner - allNetworksFailedToDisplayAd - error: $error")
    }
}

To display a banner you will need to bind it to FrameLayout or ConstraintLayout for Android and UIView for iOS

banner.bindBanner(container)

Stopping and Starting Auto-Refresh

There may be cases when you would like to stop auto-refresh, for instance, when you hide a banner ad or want to refresh it manually.

Stop auto-refresh for a banner ad with the following code:

banner.stopAutorefresh()

Start auto-refresh for a banner ad with the following code:

banner.startAutorefresh(30.0)

Manually refresh the contents with the following code. You must stop auto-refresh prior to calling refreshAd.

banner.refresh()

Destroying Banners

Once you're finished with a banner ad, it's essential to clean up its resources by invoking the destroy() method. Neglecting this step could lead to a deterioration in your app's performance

banner.destroy()
banner.destroy()

PreviousRewarded AdsNextUnreal Engine

Last updated 11 months ago

Was this helpful?