Ad did fail to present full screen content while showing Interstitial Google ads shows the error for me in iOS objective -C


I am getting this error and my code is below

 - (void)viewWillAppear:(BOOL)animated {
      NSLog(@"self.inter eve reload cl %@", self.interstitial);
      DebugAssert(index != NSNotFound);
      double delayInSeconds = 5.0;
      dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
           if (!didPurchaseAds) {
                dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
                NSLog(@"Interstitial ad loaded %ld", (long)index);
                    if ((index % 2 == 0)) {
                         NSLog(@"Interstitial ad loaded for even num %ld", (long)index);
                            if (self.interstitial) {
                                NSLog(@"Show InterstitialAd %@", self.interstitial);
                                [self.interstitial presentFromRootViewController:self];
                                [self.interstitial presentFromRootViewController:self];
                              } else {
                                NSLog(@"Ad wasn't ready event");
                           }
                        }
                  });
          }
    }
    
    - (void)viewDidLoad{
       [super viewDidLoad];
        [self loadInterstitial];
    }
    
    - (void)loadInterstitial {
            GADRequest *request = [GADRequest request];
            [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"
                                        request:request
                              completionHandler:^(GADInterstitialAd *ad, NSError *error) {
                if (error) {
                    NSLog(@"Failed to load interstitial ad with error: %@", [error localizedDescription]);
                    return;
                }
                self.interstitial = ad;
                self.interstitial.fullScreenContentDelegate = self;
            }];
        }
    
    
    - (void)ad:(nonnull id<GADFullScreenPresentingAd>)ad
    didFailToPresentFullScreenContentWithError:(nonnull NSError *)error {
        NSLog(@"Ad did fail to present full screen content.");
    }
    
    /// Tells the delegate that the ad will present full screen content.
    - (void)adWillPresentFullScreenContent:(nonnull id<GADFullScreenPresentingAd>)ad {
        NSLog(@"Ad will present full screen content.");
    }
    
    /// Tells the delegate that the ad dismissed full screen content.
    - (void)adDidDismissFullScreenContent:(nonnull id<GADFullScreenPresentingAd>)ad {
       NSLog(@"Ad did dismiss full screen content.");
    }
    
  

 

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img