Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find out if AdMob has loaded an ad?

I'm using AdMob as backup for iAd, but I'm having trouble finding out if AdMob delivers.. With iAd I could check with isBannerLoaded or something, but not with AdMob.. Anyway, I've got everything working now, except when theres no internet connection! When iAd fails to load an ad, and calls didFailToReceiveAdWithError, then I initiate the AdMob. When testing this, the Error-reason I'm using is "no internet connection", but AdMob doesn't call it's own didFailToReceiveAdWithError. It seems like no internet connection isn't an error for AdMob (GADBannerView*)

How can I tell if GADBannerView fails?

EDIT

Okay, so here's basically code I have:

-(void)viewDidLoad
{
    [super viewDidLoad];
    [self initiAdBanner];
    [self initAdMobBanner];
}

-(void)initAdMobBanner{}//initiates variable adMobBannerView(GADBannerView)
-(void)initiAdBanner{}//initiates variable iAdBannerView(ADBannerView)

-(void)hideBanner:(UIView*)banner{} //hides banner if visible
-(void)showBanner:(UIView*)banner{} //shows banner if hidden

//blah blah

-(void)adView:(GADBannerView*)banner didFailToReceiveAdWithError:(GADRequestError*)error
{
    //Never gets called, should be called when both iAd and AdMob fails.
    NSLog(@"AdMobBanner failed.");
    [self hideBanner:banner];
}

-(void)bannerView:(ADBannerView*)banner didFailToReceiveAdWithError:(NSError*)error
{
    //If iAd fails, due to no internet connection or whatever, then it calls this.
    [self adMobRequest];
    [self hideBanner:iAdBannerView];
    [self showBanner:adMobBannerView];
} 

When iAd fails and calls for (ADBannerView*)didFailToReceiveAdWithError, I start the AdMob, but when theres no internet connection, the AdMob won't call the (GADBannerView*)didFailToReceiveAdWithError. Why?

like image 916
Sti Avatar asked Oct 06 '22 11:10

Sti


1 Answers

AdMob will invoke didFailToReceiveAdWithError if there is no internet connection. Make sure you register the delegate to listen for callback methods:

[bannerView_ setDelegate:self];

You should also consider AdMob Mediation instead of trying to roll your own mediation solution. You can just create a mediation placement in the AdMob UI, add in the iAd adapter to your project, and request an ad with the mediation placement ID, and the ad showing through different networks will be done for you.

like image 109
Eric Leichtenschlag Avatar answered Oct 13 '22 12:10

Eric Leichtenschlag