My iAd/AdMob mediation works fine with all iOS 7 simulators and devices. However, iOS 8 didFailToReceiveAdWithError method doesn't work for any simulators but it works for iOS 8 devices. Problem is I don't have an iPhone 6/6+ device to test. So i'm counting on iOS 8 simulator.
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
[UIView beginAnimations:nil context:NULL];
iAd.frame=CGRectOffset (iAd.frame 0, -667);
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
iAd.frame=CGRectOffset (iAd.frame 0, 0);
[UIView commitAnimations];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
[UIView beginAnimations:nil context:NULL];
iAd.frame=CGRectOffset (iAd.frame 0, -740);
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
AdMob.frame=CGRectOffset (iAd.frame 0, -667);
[UIView commitAnimations];
}
I don't even know if the didFailToReceive coordinates are correct since I have no way to test. I don't understand why didFailToReceiveAdWithError is never called for iOS 8 simulators only? Is this an iOS 8 simulator bug or is there something I can do to fix this issue?
// ignore ^^
-(AppDelegate *)appdelegate{
return (AppDelegate *) [[UIApplication sharedApplication] delegate];
}
-(void)viewWillAppear:(BOOL)animated{
//iAD
_iAdView= [[self appdelegate] iAdView];
_iAdView.delegate=self;
screenBounds = [[UIScreen mainScreen] bounds];
[_iAdView setFrame:CGRectMake(0, 0, _iAdView.bounds.size.width, _iAdView.bounds.size.height)];
_iAdView.center = CGPointMake(screenBounds.size.width / 2, screenBounds.origin.y + (_iAdView.bounds.size.height / 2));
[self.view addSubview:_iAdView];
//ADMOB
_adMobView= [[self appdelegate] adMobView];
_adMobView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
_adMobView.adUnitID = @"My-Unit-ID";
_adMobView.rootViewController = self;
GADRequest *request =[GADRequest request];
request.testDevices = @[ @"Test-Number" ];
[_adMobView loadRequest:request];
[_adMobView setFrame:CGRectMake(0, 0, _adMobView.bounds.size.width, _adMobView.bounds.size.height)];
_adMobView.center = CGPointMake(screenBounds.size.width / 2, screenBounds.size.height - (_adMobView.bounds.size.height / 2));
[self.view addSubview:_adMobView];
}
-(void)viewWillDisappear:(BOOL)animated{ //Whether I remove this or not, nothing changes
//iAD
_iAdView.delegate = nil;
_iAdView=nil;
_iAdView.alpha=0.0;
//ADMOB
_adMobView.delegate=nil;
_adMobView=nil;
_adMobView.alpha=0.0;
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
NSLog(@"iAd received");
_iAdView.alpha=1.0;
_adMobView.alpha = 0.0;
[UIView commitAnimations];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
NSLog(@"iAd failed, AdMob received");
_iAdView.alpha=0.0;
_adMobView.alpha=1.0;
[UIView commitAnimations];
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…