Help with iAds

Hi all,

I’m using the code below to display iAds at the top of my screen and disable them when it detects the ‘End iAds’ gameobject.

But I am having a couple of problems:

  1. If a banner doesn’t load, the app crashes when it tries to banner.Hide();
  2. When the test banner does load and it tries to refresh, if it does not receive a refreshed ad i just get a white banner across the
    top of my screen. and the banner.Hide(); command doesn’t remove it.
pragma strict
private var banner : ADBannerView = null;

function Start () {

		banner = new ADBannerView();
        banner.autoSize = true;
        banner.autoPosition = ADPosition.Top;
        StartCoroutine(ShowBanner());
}

function ShowBanner () {
    yield WaitForSeconds (2.0f);
    StartCoroutine(ShowBanner2());
    }
   
function ShowBanner2() {
    while (!banner.loaded  banner.error == null)
        yield;
        
    if (banner.error == null)
        banner.Show();
    else banner = null;
}

function Update () {

if (GameObject.Find("End iAds") != null)
	{
		banner.Hide();
	}
}

Any help would be appreciated.

Thanks.

For issue #1 you could just check banner.loaded first like in your ShowBanner2 function (by the way, seems to me you could merge ShowBanner and ShowBanner2). For issue #2, I submitted a bug report for that last year, but you could submit another one and see if it gets more attention.

Thanks for the info!

By the way, issue #2 is why I’m still using the prime31 iAd plugin.

just fyi
for 4.3 (yeah, i know it is not quite around the corner) we rewrote iAD completely and greatly simplified script API. Sure, both points are solved 8)

iAds have been around for years why has it taken so long to sort out?, a bug report was submitted a year ago.

Changed the Update function to this in the end, seems to be working.

function Update () {

if (banner.error)
	{
	banner.Hide();
	StartCoroutine(ShowBanner2());     //immediately tries to load banner again
	}

else{

if (GameObject.Find("End iAds") != null)
	{
		if (banner.loaded)
		{
			banner.Hide();
		}
	}