如何在ios中以编程方式关闭非页内广告

时间:2014-10-07 06:06:45

标签: ios admob

我已成功为我的iOS应用整合了插页式广告。我知道在该广告视图中有一个关闭按钮,我们可以在点击该按钮后将其关闭。

但我希望在3秒后以编程方式关闭此广告视图。但我不知道解雇此广告的方法是什么。

----更新-----

- (void)viewDidLoad
{
    [super viewDidLoad];
    singletonClassObject=[Singleton SharedManager];

    //--------ADMOB FULLSCREEN----------
    self.interstitial = [[GADInterstitial alloc] init];
    self.interstitial.delegate = self;

    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, @"MY_TEST_DEVICE_ID" ];
    [self.interstitial loadRequest:request];
    //--------END OF AD MOB FULLSCREEN---------
}

这是在点击事件中显示广告的方式

  if ([self.interstitial isReady]) {
     [self.interstitial presentFromRootViewController:self];
  }

这些是在app解雇,显示等时触发的代表

/// Called when an interstitial ad request succeeded.
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad {
    NSLog(@"interstitialDidReceiveAd");
}

/// Called when an interstitial ad request failed.
- (void)interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error {
    NSLog(@"interstitialDidFailToReceiveAdWithError: %@", [error localizedDescription]);
}

/// Called just before presenting an interstitial.
- (void)interstitialWillPresentScreen:(GADInterstitial *)ad {
    NSLog(@"interstitialWillPresentScreen");
}

/// Called before the interstitial is to be animated off the screen.
- (void)interstitialWillDismissScreen:(GADInterstitial *)ad {
    NSLog(@"interstitialWillDismissScreen");

    //[viewAdd removeFromSuperview];
    [self.view removeFromSuperview];
}

/// Called just after dismissing an interstitial and it has animated off the screen.
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad {
    NSLog(@"interstitialDidDismissScreen");
    [self.view removeFromSuperview];
}

/// Called just before the application will background or terminate because the user clicked on an
/// ad that will launch another application (such as the App Store).
- (void)interstitialWillLeaveApplication:(GADInterstitial *)ad {
    NSLog(@"interstitialWillLeaveApplication");
}

2 个答案:

答案 0 :(得分:6)

虽然没有记录,但我发现间质可以被解雇:

[self dismissViewControllerAnimated:YES completion:NULL]; 

调用ViewController呈现非页内广告

向后工程,插页式广告必须由presentViewController呈现:动画:完成:

答案 1 :(得分:0)

好吧不幸的是你不可能做到这一点。

看看这个:Cocoadocs docsets Google Mobile Ads