Two banner ads

Hi
Is it possible to ad two banners on one screen. ?
I tried

void Start()
{
StartCoroutine(ShowBannerWhenReady());
StartCoroutine(ShowBannerWhenReady2());
}

IEnumerator ShowBannerWhenReady()
{
Advertisement.Banner.SetPosition(BannerPosition.BOTTOM_CENTER);
while (!Advertisement.IsReady(placementId))
{
yield return new WaitForSeconds(0.5f);
}
Advertisement.Banner.Show(placementId);
}

IEnumerator ShowBannerWhenReady2()
{
Advertisement.Banner.SetPosition(BannerPosition.TOP_CENTER);
while (!Advertisement.IsReady(placementId2))
{
yield return new WaitForSeconds(0.5f);
}
Advertisement.Banner.Show(placementId2);
}

But only one banner show.

@DaReign

Currently, that is not possible with the Ads SDK as it is implemented in Unity. It is possible to create multiple banners if you are using the native iOS or native Android version of the SDK. This is because on the native side, you have more control over the actual views that are created at the OS level.

I don’t think we currently have any plans to offer multiple banners within Unity, as a single banner covers the majority of the use cases. However, the SDK team is always considering new features, so we will re-evaluate if it makes sense to add that as a feature.

Hello,

I have added one banner object every scene however there are double banners in every scene for IOS version. I checked my code and I couldn’t see any problem. My banner code is same Admob adaptive banner code. There no problem in Android version. The poblem is only for IOS.

How can it be? Could you please help me?

My banner code is below:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using GoogleMobileAds.Api;

public class BannerReklam : MonoBehaviour
{
private BannerView bannerView;

// Use this for initialization
void Start()
{
// Initialize the Google Mobile Ads SDK.
//MobileAds.Initialize(initStatus => { });

RequestBanner();
}

public void OnGUI()
{
GUI.skin.label.fontSize = 60;
Rect textOutputRect = new Rect(
0.15f * Screen.width,
0.25f * Screen.height,
0.7f * Screen.width,
0.3f * Screen.height);
GUI.Label(textOutputRect, “”);
}

private void RequestBanner()
{
// These ad units are configured to always serve test ads.
#if UNITY_EDITOR
string adUnitId = “unused”;
#elif UNITY_ANDROID
string adUnitId = “ca-app-pub-1111111111111111/11111111111”;
#elif UNITY_IPHONE
string adUnitId = “ca-app-pub-1111111111111111/11111111111”;
#else
string adUnitId = “unexpected_platform”;
#endif

// Clean up banner ad before creating a new one.
if (this.bannerView != null)
{
this.bannerView.Destroy();
}

AdSize adaptiveSize =
AdSize.GetPortraitAnchoredAdaptiveBannerAdSizeWithWidth(AdSize.FullWidth);

this.bannerView = new BannerView(adUnitId, adaptiveSize, AdPosition.Bottom);

// Register for ad events.
this.bannerView.OnAdLoaded += this.HandleAdLoaded;
this.bannerView.OnAdFailedToLoad += this.HandleAdFailedToLoad;
this.bannerView.OnAdOpening += this.HandleAdOpened;
this.bannerView.OnAdClosed += this.HandleAdClosed;
this.bannerView.OnAdLeavingApplication += this.HandleAdLeftApplication;

AdRequest adRequest = new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator)
.AddTestDevice(“0123456789ABCDEF0123456789ABCDEF”)
.Build();

// Load a banner ad.
this.bannerView.LoadAd(adRequest);
}

#region Banner callback handlers

public void HandleAdLoaded(object sender, EventArgs args)
{
MonoBehaviour.print(“HandleAdLoaded event received”);
MonoBehaviour.print(String.Format(“Ad Height: {0}, width: {1}”,
this.bannerView.GetHeightInPixels(),
this.bannerView.GetWidthInPixels()));
}

public void HandleAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
MonoBehaviour.print(
"HandleFailedToReceiveAd event received with message: " + args.Message);
}

public void HandleAdOpened(object sender, EventArgs args)
{
MonoBehaviour.print(“HandleAdOpened event received”);
}

public void HandleAdClosed(object sender, EventArgs args)
{
MonoBehaviour.print(“HandleAdClosed event received”);
}

public void HandleAdLeftApplication(object sender, EventArgs args)
{
MonoBehaviour.print(“HandleAdLeftApplication event received”);
}

#endregion
}

1 Like