IOS Interstitial iAd not closing

my iAd integration is not working correctly. I tried to implement fullscreen ads. The ad appears, but when I press the "X" button to close, it does not close.

Perhaps you can find the problem in my code? I do not know what to change, and I spent a lot of time fixing the problem without success.

UPDATE

It works with [interstitial presentFromViewController:self];, but not with. [interstitial presentInView:self.view];  The problem is that presentFromViewController is deprecated with iOS 7 ... so how do I change it?


- (void)viewDidLoad
    {
        requestingAd = NO;
        [self showFullScreenAd];

    }

//Interstitial iAd
    -(void)showFullScreenAd {
        //Check if already requesting ad
        if (requestingAd == NO) {
            interstitial = [[ADInterstitialAd alloc] init];
            interstitial.delegate = self;
            self.interstitialPresentationPolicy = ADInterstitialPresentationPolicyManual;
            [self requestInterstitialAdPresentation];
            NSLog(@"interstitialAdREQUEST");
            requestingAd = YES;
        }//end if
    }

    -(void)interstitialAd:(ADInterstitialAd *)interstitialAd didFailWithError:(NSError *)error {
        interstitial = nil;
        requestingAd = NO;
        NSLog(@"interstitialAd didFailWithERROR");
        NSLog(@"%@", error);
    }

    -(void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd {
        NSLog(@"interstitialAdDidLOAD");
        if (interstitialAd != nil && interstitial != nil && requestingAd == YES) {
    [interstitial presentInView:self.view];
            NSLog(@"interstitialAdDidPRESENT");
        }//end if
    }

    -(void)interstitialAdDidUnload:(ADInterstitialAd *)interstitialAd {
        interstitial = nil;
        requestingAd = NO;
        NSLog(@"interstitialAdDidUNLOAD");
    }

    -(void)interstitialAdActionDidFinish:(ADInterstitialAd *)interstitialAd {
        interstitial = nil;
        requestingAd = NO;
        NSLog(@"interstitialAdDidFINISH");
    }

Thanks in advance:)

+4
source share
2 answers

. , , InView.

, , - [self requestInterstitialAdPresentation]. ... , , API iAd.

- , , , . - [UIView prepareInterstitialAds] AppDelegate. , .

, . .

+4

, [interstitial presentInView:self.view]; [_interstitialAd presentInView:_adPlaceholderView];, _adPlaceholderView , self.view, . , .

:

-(void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd
{
    if ((interstitialAd != nil) && (_interstitialAd != nil) && (_requestingAd))
    {
        _adPlaceholderView = [[UIView alloc] initWithFrame:self.view.bounds];
        [self.view addSubview:_adPlaceholderView];
        [_interstitialAd presentInView:_adPlaceholderView];
    }
}

-(void)interstitialAdActionDidFinish:(ADInterstitialAd *)interstitialAd
{
    _interstitialAd = nil;
    _requestingAd = NO;
    [_adPlaceholderView removeFromSuperview];
    _adPlaceholderView = nil;
}

, .

+4

Source: https://habr.com/ru/post/1532205/


All Articles