【问题标题】:Google AdMobs interstitial on reopening timed out重新打开时 Google AdMob 插页式广告超时
【发布时间】:2013-06-28 17:59:45
【问题描述】:

我想在我的应用程序中添加一些广告,尤其是应用程序进入前台时的插页式广告。

我在我的 AppDelegate.m 中创建了这个方法:

- (void)splashInterstitial
{
    UIImage *image;

    if (TEST_IPHONE_5) {
        image = [UIImage imageNamed:@"Default-568h.png"];
    } else {
        image = [UIImage imageNamed:@"Default.png"];
    }

    splashInterstitial_ = [[DFPInterstitial alloc] init];
    splashInterstitial_.adUnitID = ADMOBS_OUVERTURE;
    [splashInterstitial_ loadAndDisplayRequest:[GADRequest request]
                                   usingWindow:self.window
                                  initialImage:image];

}

我调用了两次: - 在application:didFinishLaunchingWithOptions: - 在applicationWillEnterForeground:

application:didFinishLaunchingWithOptions: 中调用时它工作正常,但在第二种情况下,我有这个错误:

Google 请求错误:无法满足 Google 广告请求 在发生超时之前。

显然,加载需要 5 秒,但我不知道如何强制我的应用程序等待它。

有人知道怎么做吗?

感谢您的帮助。

【问题讨论】:

    标签: ios admob interstitial


    【解决方案1】:

    loadAndDisplayRequest:usingWindow:initialImage: 方法存在一些问题。 This blog post 解释了如何使用 GADInterstitial 的 loadRequest: 方法实现相同的目标。这种实现更好,因为您可以更好地控制视图层次结构。

    【讨论】:

      【解决方案2】:

      我已经了解了如何在首次启动时以及每次应用启动时使用插页式广告。

      您只需在applicationDidBecomeActive: 中调用我的方法(void)splashInterstitial 一次。

      - (void)applicationDidBecomeActive:(UIApplication *)application
      {
          // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
      
          // ADMobs
          [self splashInterstitial];
      
      }
      
      
      - (void)splashInterstitial
      {
          UIImage *image;
      
          if (TEST_IPHONE_5) {
              image = [UIImage imageNamed:@"Default-568h.png"];
          } else {
              image = [UIImage imageNamed:@"Default.png"];
          }
      
          splashInterstitial_ = [[DFPInterstitial alloc] init];
          splashInterstitial_.adUnitID = ADMOBS_OUVERTURE;
          [splashInterstitial_ loadAndDisplayRequest:[GADRequest request]
                                         usingWindow:self.window
                                        initialImage:image];
      
      }
      

      【讨论】:

      • 我在 xcode 6.1 中试过这个代码。Admob Sdk 是 6.12.2。我看过官方的谷歌 admob 教程,但官方网站上没有代码。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-21
      相关资源
      最近更新 更多