Search code examples
iosios7admob

GADInterstitial not firing any delegate methods on iOS


I am trying to integrate AdMob's interstitial ads into my iOS, but even though everything seems okay, I am not getting any of the interstitial delegate methods (including failure too) fired. I have set my ad as an interstitial Ad and I have my Ad unit ID correct. Here is my code:

GADInterstitial *interstitialAd = [[GADInterstitial alloc] init];
interstitialAd.adUnitID = AD_UNIT_ID;
interstitialAd.delegate = self;
GADRequest *adRequest = [GADRequest request];
#if DEBUG
adRequest.testDevices = @[ @"9ab869b041b0e1d5a362be13c99eb69a" ];
#endif
[interstitialAd loadRequest:adRequest];

I've got a breakpoint at the above code and it is firing. Then, at the same class, I've got the delegate methods implemented:

-(void)interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error{
    loadedAd = nil;
}

-(void)interstitialDidReceiveAd:(GADInterstitial *)ad{
    loadedAd = ad;
    [self presentAdIfAppropriate];
}

However, neither of these methods are being called, even after waiting for minutes. I have a stable internet connection on my device, and the connection timeout is set as 4 seconds at AdMob website. Why doesn't my ad load?


Solution

  • You should keep a strong reference (in the class scope) on the interstitial ad object as it will be probably released after you load the request (as it is defined in the local scope of your request method).