Search code examples
iosadmobiadmediator

Can't get iad/adMob to mediate on device


I'm using GoogleMobileAdsSDKiOS 7.0.0. I followed Google's AdMob instructions for setting up AdMob then I followed mediation instructions. Mediation with iAd/AdMob works well on simulator but never works on device. iAd almost never fails and when it does AdMob test banner never loads.

 - (void)viewDidLoad
{

[super viewDidLoad];



self.adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, 60, 320, 50)];  
self.adView.delegate = self;

[self.view addSubview:adView]; 
}



 -(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{

self.adView.hidden=YES;

NSLog(@"Google Mobile Ads SDK version: %@7.0.0", [GADRequest sdkVersion]);

self.adBanner_=[[GADBannerView alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];

self.adBanner_.adUnitID = @"my-ID";   

self.adBanner_.rootViewController=self;

[self.view addSubview:self.adBanner_];

GADRequest *request =[GADRequest request];

request.testDevices = @[ @"2077ef9a63d2b398840261c8221a0c9b"];    

[self.adBanner_ loadRequest:request];

}

I also tried the bannerViewDidLoadAd to show that adView loads but that only made AdMob and iAd load at the same time so I can't use bannerViewDidLoadAd.

I can't figure out why AdMob/iAd don't mediate on device yet work perfectly fine on simulator. Can't figure out why AdMob never loads test banner on device.


Solution

  • You should hide adview in viewDidLoad and then unhide it in bannerViewDidLoadAd. However, your code looks fine. From my experience with iad/admob mediation it takes a longer time for iAd to fail on actual device than it does on simulator. On actual device, you'll see after iAd fails then AdMob will load but i'll take time before it happens as opposed to on simulator as soon as iAd fails, AdMob loads. Not so on device. That's how i have it. Test it and wait a bit.