我正在使用admob的DoubleClick(dfp)广告。
我想在几秒钟后关闭/关闭插页式广告。
(只要用户没有点击广告)。

我可以执行dismissModalViewControllerAnimated afterDelay,但是即使用户单击它们,它也会关闭广告。

有什么建议么?

最佳答案

您必须实现<GADInterstitialDelegate>委托并实现委托的方法interstitialWillDismissScreen:(GADInterstitial *)ad

#import "MainViewController.h"
#import "GADInterstitial.h"

@interface MainViewController ()<GADInterstitialDelegate>
@property(nonatomic, strong) GADInterstitial *interstitial;


@end

@implementation MainViewController


- (void)viewDidLoad {
    [super viewDidLoad];


   self.interstitial = [[GADInterstitial alloc] init];
   self.interstitial.adUnitID = @"ca-app-pub-3940256099942544/4411468910";

    GADRequest *request = [GADRequest request];
   // Requests test ads on simulators.
   request.testDevices = @[ GAD_SIMULATOR_ID ];
   [self.interstitial loadRequest:request];


}
-(void)interstitialDidReceiveAd:(GADInterstitial *)ad
{
    NSLog(@"interstitialDidReceiveAd successfully");
    [ad presentFromRootViewController:self];
}
-(void)interstitialWillDismissScreen:(GADInterstitial *)ad{
  NSLog(@"interstitial is going to dismiss");


}


这是必须自动关闭您的插页式广告。

08-26 07:59