【问题标题】:adMob not working with test ad on real deviceadMob 无法在真实设备上使用测试广告
【发布时间】:2018-07-23 01:35:20
【问题描述】:

我已添加代码以在我的应用程序中添加 admob。测试 adunit 在模拟器上提供测试广告,但不在真实设备上。尽管我已在测试设备中添加了我的设备 ID。 我在link 上找到了答案,但它是关于没有展示的真实广告。但就我而言,它也没有显示测试广告。 这是我正在使用的代码。

bannerView = GADBannerView(adSize: kGADAdSizeBanner)
    bannerView.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(bannerView)
    view.addConstraints(
        [NSLayoutConstraint(item: bannerView,
                            attribute: .bottom,
                            relatedBy: .equal,
                            toItem: bottomLayoutGuide,
                            attribute: .top,
                            multiplier: 1,
                            constant: 0),
         NSLayoutConstraint(item: bannerView,
                            attribute: .centerX,
                            relatedBy: .equal,
                            toItem: view,
                            attribute: .centerX,
                            multiplier: 1,
                            constant: 0)
        ])
    bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716"
    bannerView.rootViewController = self
    bannerView.load(GADRequest())
    let requestAd:GADRequest = GADRequest()
    requestAd.testDevices = [kGADSimulatorID, "b8e41041fae0a22d8d95ff6b9c0e003a"]
    bannerView.load(requestAd)

【问题讨论】:

    标签: ios swift admob


    【解决方案1】:

    按照以下步骤操作:

    1. 产品
    2. 方案
    3. 论据
    4. 环境变量

    有一个名为OS_ACTIVITY_MODE 的设置。您必须删除或禁用该密钥。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多