2
\$\begingroup\$

I can show interstitial AdMob ads with the following code:

    if (GUI.Button(new Rect(10, 300, 150, 50), "Load Interstitials"))
    {           
        interstitial.LoadAd(interstitialsRequest); 
    }

    if (GUI.Button(new Rect(10, 400, 150, 50), "Show Interstitials"))
    {       
        if (interstitial.IsLoaded())
        {
            interstitial.Show();
        }
    }

That's all working well.

Now I want to attach a listener for when the interstitial ad has loaded. I checked all the available source files, but can't find the right listener method.

void onAdLoaded()
{
    print("Interstitial Ad Loaded");        
}

public void HandleAdLoaded(object sender)
{
    print("HandleAdLoaded event received.");       
    // Handle the ad loaded event.
}

I use googleads-mobile-plugins for Admob ads.

What listener should I be using?

\$\endgroup\$
3
\$\begingroup\$

There are several different events that can be called from the interstitial, AdLoaded, AdOpened, AdClosing, and AdClosed. Unfortunately it appears this is as much interaction as you can have with the interstitial that google exposes.

Digging deeper, if we look at the source of InterstitialAd, then we find it inherits from IAdListener, which only exposes the events

void FireAdLoaded();
void FireAdFailedToLoad(string message);
void FireAdOpened();
void FireAdClosing();
void FireAdClosed();
void FireAdLeftApplication();

At this point, you can add your own events. Then, simply reimplement them in InterstitialAd's source.

\$\endgroup\$
  • \$\begingroup\$ Means if I write above methods in my custom script then it gets called. Am I right? \$\endgroup\$ – Siddharth Aug 19 '14 at 17:01
  • \$\begingroup\$ @Siddharth You would have to add the code that calls them in InterstitialAd's source... You may have to dig into the java source too \$\endgroup\$ – Liam McInroy Aug 19 '14 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.