Search code examples
iosobjective-cinterstitial

Interstitial don't appear.


I use this code for add interstitial:

    - (void)applicationDidBecomeActive:(UIApplication *)application
{
    GADRequest *request = [GADRequest request];

    request.testDevices = [NSArray arrayWithObjects:
                           GAD_SIMULATOR_ID,
                           nil];



    gadinter = [[GADInterstitial alloc] init];
    gadinter.delegate = self;
    gadinter.adUnitID = @"ca-app-pub-8360827428091030/4165686904";

    [gadinter loadRequest:request];
}

- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial {

    [gadinter presentFromRootViewController:self.window.rootViewController];
}

and i'm getting this :

2015-02-09 18:57:12.636 iStrobe[5951:1824030] <Google> Cannot present interstitial. It is not ready. 2015-02-09 18:57:13.801 iStrobe[5951:1824030] <Google> No UIViewController supplied to the ad. Cannot continue.

Any ideea why ? In others app it works.


Solution

  • In my viewController i added it this :

    - (void)viewDidLoad {
    
    
        GADRequest *request = [GADRequest request];
    
        request.testDevices = [NSArray arrayWithObjects:
                               GAD_SIMULATOR_ID,
                               nil];
    
    
    
        gadinter = [[GADInterstitial alloc] init];
        gadinter.delegate = self;
        gadinter.adUnitID = @"ca-app-pub-8360827428091030/4165686904";
    
        [gadinter loadRequest:request];
    
    }
    
    - (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial {
        [gadinter presentFromRootViewController:self];
    }