我用Swift编写了这段代码,这样当我按下一个按钮时,就会出现Ad团广告,而现在我的应用程序正在显示一个测试广告。我的问题是我怎样才能从展示测试广告过渡到现实世界的广告?顺便说一下,我在Xcode上使用模拟器,因为我没有iPhone!
import UIKit
import Parse
import GoogleMobileAds
class NewsPageViewController: UIViewController {
var interstitial:GADInterstitial!
override func viewDidLoad() {
super.viewDidLoad()
self.interstitial = self.createAndLoadAd()
}
func createAndLoadAd() -> GADInterstitial {
interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
var request = GADRequest()
request.testDevices = ["2077ef9a63d2b398840261c8221a0c9b"]
interstitial.loadRequest(request)
return interstitial
}
@IBAction func buttonTapped(sender: AnyObject) {
if (self.interstitial.isReady) {
self.interstitial.presentFromRootViewController(self)
self.interstitial = self.createAndLoadAd()
}}
发布于 2015-12-15 16:01:57
这样做:
1-删除"request.testDevices =“2077 ef9a63d2b398840261c8221a0c9b”
2-在谷歌网站上创建一个adUnitID账号,然后在你的账户中创建一个应用程序,然后用创建的应用程序替换默认的谷歌教程中给出的。
然后,代替测试广告,你可能会得到一个全黑屏幕广告。这一次是因为谷歌需要几个小时才能开始发送真正的广告。希望这能有所帮助。
https://stackoverflow.com/questions/34282980
复制相似问题