iAd fallback to AdMob

Hi,

I am trying to get my iAd code (which is working perfectly), to fall back to AdMob (using Prime31’s plugin) when there are no ads being served from Apple.

Here’s the code I am using:

#pragma strict

import System.Collections.Generic;

// Bard iAd

 var banner:ADBannerView;

function Start () {

// Bard iAd + AdMob + Chartboost

    StartCoroutine(ShowBanner());
    ChartBoostBinding.showInterstitial( "default" );
    AdMobBinding.init( "a1518d4a265caae", true );

}


function Update () {
}


function Awake () {
    ChartBoostBinding.cacheInterstitial( "default" );

}

 

function ShowAdsChartboost () {

    ChartBoostBinding.showInterstitial( "default" );

}


// Bard iAd

function ShowBanner() {


    banner = new ADBannerView();

    banner.autoSize = true;

    banner.autoPosition = ADPosition.Bottom;

    Debug.Log(banner.error);

    while (!banner.loaded && banner.error == null)

        yield;

    if (banner.error == null)

        banner.Show();
    
    else banner = null;

}

I tried changing a part of my ShowBanner function to:

if(banner.error == false) {

    banner.Show();

} else if(banner.error == true) {

    AdMobBinding.createBanner( AdMobBannerType.iPhone_320x50, AdMobAdPosition.BottomRight );

}

But that didn’t work on the device… Has anyone done this? Would love to get some tips on this.

yeah, but not with this script. I just bought the AdMob plugin from Prime31 for unity. works great and it will serve iAds, Google Ads, etc. with a control over which is served first from the AdMob website.

You can do that directly from admob’s portal. You click edit mediation, and you give a higher value to iads.