Jerome
Jerome

Reputation: 611

AdMob interstitial shown only once on iOS

I'm using admob interstitial on my iOS app. I'm able to display the interstitial only one time, any further request to display a new interstitial fails (delegate is never called by the way).

My code is as follow:

-(void) viewDidLoad
{
  [super viewDidLoad];
  [self allocateAndDisplayAd];
}

-(void) allocateAndDisplayAd
{
  splashInterstitial_ = [[GADInterstitial alloc] init];
  splashInterstitial_.adUnitID = @"ca-app-pub-MY-ID";
  splashInterstitial_.delegate = self;

  GADRequest *requestInterstitial = [GADRequest request];
  [splashInterstitial_ loadRequest: requestInterstitial];
}

// below functions delegate are never triggered when requesting a new interstitial !!
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad
{
    [splashInterstitial_ presentFromRootViewController: self];
}

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

- (void)interstitialDidDismissScreen:(GADInterstitial *)ad
{
  splashInterstitial_ = nil;
}

The interstitial is properly displayed when app launches (request done from the viewDidLoad), then any new request (call to allocateAndDisplayAd) fails (no error message, delegate function never called).

I tried to set splashInterstitial_ = nil; so I'm sure the next request will reallocate a new interstitial, but no way to display more than one ad.

Any help would be appreciated. Thanks

Upvotes: 2

Views: 1191

Answers (1)

Jerome
Jerome

Reputation: 611

Ok I found my issue

Any request to show interstitial from applicationWillEnterForeground will be ignored ... And my second request was done from applicationWillEnterForeground

Upvotes: 0

Related Questions