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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With