Bilal Drndo
Bilal Drndo

Reputation: 67

Implement unity banner ads in swift

I have a game that I want to implement Unity banner ads to. I have implemented Unity rewarded and interstitial ads but there is no documentation or videos about banner ads. I had Admob Ads but Google blocked my account for 30 days so I need to transfer to Unity in this month.

Upvotes: 1

Views: 466

Answers (1)

miff
miff

Reputation: 342

there is my implementation:

Create method like this:

func prepareUnityBannerAdd() {
        if UnityAds.isReady() {
            UnityAdsBanner.initialize()
            UnityAdsBanner.setDelegate(self)
            UnityAdsBanner.setBannerPosition(UnityAdsBannerPosition.topCenter)
            UnityAdsBanner.load(UNITY.banner) // This is my placment id string 
        }
}

in UnityAdsDelegate method AdsReady call like this:

func unityAdsReady(_ placementId: String) {
    prepareUnityBannerAdd()
}

and finally in UnityAdsBannerDelegate method BannerDidLoad do something like this:

func unityAdsBannerDidLoad(_ placementId: String, view: UIView) {
    bannerView.addSubview(view) // bannerView is just UIView to hold banner...
}

I hope this will help you

Upvotes: 1

Related Questions