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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在ios中以编程方式关闭非页内广告相关的知识,希望对你有一定的参考价值。

我已成功为我的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");
}
答案

虽然没有记录,但我发现插页式广告可以通过以下方式解散:

[self dismissViewControllerAnimated:YES completion:NULL]; 

在ViewController上调用了Interstitial

向后工程,插页式必须由presentViewController呈现:animated:completion:

另一答案

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

看看这个:Cocoadocs docsets Google Mobile Ads

以上是关于如何在ios中以编程方式关闭非页内广告的主要内容,如果未能解决你的问题,请参考以下文章

多按钮上的Admob非页内广告点击

AdMob非页内广告停止了工作

我的应用在显示Admob广告时崩溃(非页内广告)

Android上的非页内AdMob中介

Admob插页式广告显示带有新广告单元ID的黑色

如何在 iOS 7 中以编程方式正确关闭 UIAlertView?