Google AdMob’s first GADBannerView request is time consuming and UI dependent

I use the Google AdMob SDK (the last one downloaded most recently) in my application.

When my application launches it, it freezes for 4-5 seconds until the ad is loaded and displayed. After that, it works smoothly. When I comment out the banner request line, the application starts normally.

I created my own helper class in which I have the following code.

- (void) getGoogleBanner:(UIViewController *) targetController { self.googleBannerView.rootViewController = targetController; [self.googleBannerView.rootViewController.view addSubview:self.googleBannerView]; [self.googleBannerView setDelegate:self]; GADRequest* request = [GADRequest request]; [self.googleBannerView loadRequest:request]; } 

Where

  • googleBannerView is a property of my class and is of type GADBannerView
  • I set the frame size and ad unit ID correctly
  • targetController is a controller. I want to add a banner to
  • I call the [CustomClass getGoogleBanner: self] method in the viewDidAppear of various controllers and successfully display the banner, except for the first loading problem.

I would like to know if anyone has encountered this problem and how it is resolved. I am open to any ideas that would fix the freeze problem. I tried to run the code in the background thread, but I failed because I am not very good at it.

Any help is greatly appreciated, thanks in advance.

+7
source share
1 answer

I only have a problem when running in the simulator, so if so, you should not worry.

From what I could find, when calling the loadRequest method loadRequest environment will also call the canOpenURL: ( UIApplication ) method. Of some of the tests I performed (on both simulators and iOS devices with 5.1.1 and 6.1.3), canOpenURL sometimes freezes for several seconds on the simulator (as soon as it took 20 seconds to return), however, it works well on devices.

+2
source

All Articles