Ios AdMob Interstitual:无需加载ad(在一个项目上工作,但在另一个项目上不工作)

Ios AdMob Interstitual:无需加载ad(在一个项目上工作,但在另一个项目上不工作),ios,swift,admob,Ios,Swift,Admob,我在AdMob上遇到了一个非常奇怪的问题。在我的主项目中,我收到一个错误,即没有要加载的广告(当尝试获取gadintial时) 然而,当我创建了一个新项目,复制了AdMob相关的源代码,启动了项目,它加载了广告,没有任何问题(看起来它总是加载测试广告;我尝试了几次,只是为了确定) 在这两个项目中,我使用的是相同的谷歌播客: pod 'Google-Mobile-Ads-SDK' pod 'Google/Analytics' 我一直在尝试各种解决方案,生成不同的广告单元id,在没有分析的情况下测

我在AdMob上遇到了一个非常奇怪的问题。在我的主项目中,我收到一个错误,即没有要加载的广告(当尝试获取
gadintial
时)

然而,当我创建了一个新项目,复制了AdMob相关的源代码,启动了项目,它加载了广告,没有任何问题(看起来它总是加载测试广告;我尝试了几次,只是为了确定)

在这两个项目中,我使用的是相同的谷歌播客:

pod 'Google-Mobile-Ads-SDK'
pod 'Google/Analytics'
我一直在尝试各种解决方案,生成不同的广告单元id,在没有分析的情况下测试新项目,然后将分析附加到它。它在每一步都像一个符咒

在我的主要项目中,我曾经得到过一个广告,奇怪的是它是针对广告单位id(横幅视图)。可悲的是,从那时起,我既不能得到横幅也不能得到中间广告(我以前无法检索中间广告)

我的目标平台是iOS 8+

来源,
AdMobManager

import GoogleMobileAds

class AdMobManager {
    static let sharedInstance = AdMobManager()

    private(set) var interstitial: GADInterstitial!

    func loadInterstitialAd(delegate: GADInterstitialDelegate) -> GADInterstitial {
        interstitial = GADInterstitial(adUnitID: "same-ad-unit-id-for-both-projects")
        interstitial.delegate = delegate

        let request = GADRequest()
        request.testDevices = [ "same-test-id-for-both-projects" ]

        interstitial.loadRequest(request)
        return interstitial
    }
}
ViewController

import UIKit
import GoogleMobileAds

class ViewController: UIViewController {
    private var interstitial: GADInterstitial!

    override func viewDidLoad() {
        interstitial = AdMobManager.sharedInstance.loadInterstitialAd(self)
    }
}

extension ViewController: GADInterstitialDelegate {
    func interstitialDidReceiveAd(ad: GADInterstitial!) {
        if interstitial.isReady {
            interstitial.presentFromRootViewController(self)
        } else {
            NSLog("Not ready")
        }
    }

    func interstitial(ad: GADInterstitial!, didFailToReceiveAdWithError error: GADRequestError!) {
        NSLog("Error: \(error.debugDescription)")
    }
}

问题的原因是自定义
用户代理


由于AdMob文档没有涵盖这一点,希望能为用户节省数小时的调试时间。

您是否在两个项目中使用相同的捆绑包标识符,请确保。AdMob没有捆绑包id,对于分析,我已为两个项目设置了适当的捆绑包标识符。