gpt4 book ai didi

ios - 如何在 ios 中以编程方式关闭插页式广告

转载 作者:行者123 更新时间:2023-11-28 18:10:15 25 4
gpt4 key购买 nike

我已成功为我的 iOS 应用集成插页式广告。我知道在那个广告 View 上有一个关闭按钮,我们可以在点击该按钮后关闭它。

但我想在 3 秒后以编程方式关闭此广告 View 。但是我不知道关闭这个广告的方法是什么。

----- 已更新-----

- (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];
}

这些是在应用关闭、显示等时触发的代表

/// 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呈现:

关于ios - 如何在 ios 中以编程方式关闭插页式广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26229554/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com