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

问题描述 投票:0回答:2

我已成功为我的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");
}
ios admob
2个回答
6
投票

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

[self dismissViewControllerAnimated:YES completion:NULL]; 

在ViewController上调用了Interstitial

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


0
投票

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

看看这个:Cocoadocs docsets Google Mobile Ads

© www.soinside.com 2019 - 2024. All rights reserved.