0

for iOS, iAd/AdMob mediation only works in viewDidLoad method. It completely ignores every other method. Since iAd is added through storyboards and AdMob is added programmatically, AdMob doesn't respond to .hidden statements. Since the mediation only works in ViewDidLoad, how do I make mediation work in -(void)GameOver method for example?

For example...

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

How Would I place the above method inside of the -(void)GameOver method so the code inside the didFailToReceiveAdWithError would work in -(void)GameOver?

  -(void)bannerViewDidLoadAd:(ADBannerView *)banner{
   [UIView beginAnimations:nil context:nil];
   [UIView setAnimationDuration:0];
   [iAdBanner setAlpha:1];
   iAdBanner.hidden=NO;
   [UIView commitAnimations];
   [self.iAdBanner setDelegate:self];
   bannerView = [[GADBannerView alloc]     initWithAdSize:kGADAdSizeSmartBannerPortrait];
   }

  -(void)bannerView:(ADBannerView *)banner    didFailToReceiveAdWithError:(NSError *)error{
  [UIView beginAnimations:nil context:nil];
  [UIView setAnimationDuration:0];
  [iAdBanner setAlpha:0];
  iAdBanner.hidden=YES;
  [UIView commitAnimations];

   bannerView = [[GADBannerView alloc]  initWithAdSize:kGADAdSizeSmartBannerPortrait]; 
   bannerView=[[GADBannerView alloc]initWithFrame:CGRectMake(0, 0, 320,  50)];
   self.bannerView.adUnitID=@"Unit-ID";
   self.bannerView.rootViewController=self;
   [self.view addSubview:self.bannerView]; 
   GADRequest *request =[GADRequest request];
   request.testDevices= @[ GAD_SIMULATOR_ID ]; 
   [self.bannerView loadRequest:request];
  }
2
  • You have not provided enough information here to allow others to help you answer this question. There should be no reason why admob's view doesn't respond to setting .hidden. Ensure that it is properly added to the view and that an ad is loaded.
    – wsidell
    Jan 23, 2015 at 21:16
  • I added my code. Maybe that'll help. I've been trying to figure it out for days. Since AdMob is added programatically it never responds to bannerView.hidden=YES or NO and it doesn't mediate in -(void)GameOver method. Once AdMob banner loads in viewDidLoad, no other ads load in any other method. However, when iAd loads in viewDidLoad, only iAds load in GameOver method.
    – aliya
    Jan 23, 2015 at 21:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.