我正在使用测试广告并通过测试设备加载它。我即将把我的应用程序放在应用商店上,这样测试设备就不存在了。我知道我需要将我的广告密钥更改为真实密钥,但是我应该如何更改代码以便在用户设备而不是测试设备上加载?
func createInterstitialAd() -> GADInterstitial? {
interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
guard let interstitial = interstitial else {
return nil
}
let request = GADRequest()
request.testDevices = [kGADSimulatorID]
interstitial.load(request)
interstitial.delegate = self
return interstitial
}
在部署之前,您是否只能将生产应用程序ID编辑到您的功能中?正如Admob插页式文档中所述,“只需确保在发布应用之前将其替换为您自己的广告单元ID。”
https://developers.google.com/admob/ios/interstitial
func createAndLoadInterstitial() -> GADInterstitial {
var interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
interstitial.delegate = self
interstitial.load(GADRequest())
return interstitial
}