【问题标题】:AdMob interstitial shown only once on iOSAdMob 插页式广告在 iOS 上仅显示一次
【发布时间】:2014-06-22 10:53:17
【问题描述】:

我在我的 iOS 应用上使用 admob 插页式广告。 我只能显示一次插页式广告,任何进一步显示新插页式广告的请求都会失败(顺便说一下,永远不会调用委托)。

我的代码如下:

-(void) viewDidLoad
{
  [super viewDidLoad];
  [self allocateAndDisplayAd];
}

-(void) allocateAndDisplayAd
{
  splashInterstitial_ = [[GADInterstitial alloc] init];
  splashInterstitial_.adUnitID = @"ca-app-pub-MY-ID";
  splashInterstitial_.delegate = self;

  GADRequest *requestInterstitial = [GADRequest request];
  [splashInterstitial_ loadRequest: requestInterstitial];
}

// below functions delegate are never triggered when requesting a new interstitial !!
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad
{
    [splashInterstitial_ presentFromRootViewController: self];
}

- (void)interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error
{
  splashInterstitial_ = nil;
}

- (void)interstitialDidDismissScreen:(GADInterstitial *)ad
{
  splashInterstitial_ = nil;
}

应用启动时插页式广告会正确显示(从 viewDidLoad 完成请求),然后任何新请求(调用 allocateAndDisplayAd)都会失败(没有错误消息,从未调用委托函数)。

我试图设置 splashInterstitial_ = nil;所以我确信下一个请求会重新分配一个新的插页式广告,但无法显示多个广告。

任何帮助将不胜感激。 谢谢

【问题讨论】:

  • 首先:确保splashInterstitial_在使用后必须被dealloc(你可以覆盖GADInterstitial类来确定)。第二:你在哪里声明splashInterstitial_
  • 您好我在 Xcode 中使用 arc 是我无法使用释放功能。 splashInterstitial_ = nil;应该释放对象。对象 splashInterstitial_ 在我的视图控制器的 .h 中声明。感谢您的回答杰罗姆
  • 您是否收到任何错误?
  • 不,正如我在原帖中提到的,不再调用委托函数。
  • 您何时以及如何致电allocateAndDisplayAd

标签: ios admob interstitial


【解决方案1】:

好的,我找到了我的问题

来自 applicationWillEnterForeground 的任何显示插页式广告的请求都将被忽略... 我的第二个请求是从 applicationWillEnterForeground 完成的

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-21
    • 1970-01-01
    • 2021-11-24
    • 1970-01-01
    • 2019-04-11
    相关资源
    最近更新 更多