我正在尝试将插页式广告AdMob应用到我的游戏应用中。但到目前为止我没有太多运气。代码似乎没有错误,但它不显示应用程序。任何帮助都会非常感激。谢谢! 这是我的代码:
import UIKit
import SpriteKit
import GoogleMobileAds
class GameViewController: UIViewController, GADInterstitialDelegate {
var interstitial: GADInterstitial!
override func viewDidLoad() {
super.viewDidLoad()
if let scene = GameScene(fileNamed:"GameScene") {
// Configure the view.
let skView = self.view as! SKView
skView.showsFPS = true
skView.showsNodeCount = true
/* Sprite Kit applies additional optimizations to improve rendering performance */
skView.ignoresSiblingOrder = true
/* Set the scale mode to scale to fit the window */
scene.scaleMode = .AspectFill
skView.presentScene(scene)
}
interstitial = GADInterstitial(adUnitID: "ca-app-pub-5713504307801022/7610056592")
let request = GADRequest()
interstitial.loadRequest(request)
func CreateAD() -> GADInterstitial {
let interstital = GADInterstitial(adUnitID: "ca-app-pub-5713504307801022/7610056592")
interstitial.loadRequest(GADRequest())
return interstital
}
if gameOver == true {
if (interstitial.isReady){
interstitial.presentFromRootViewController(self)
interstitial = CreateAD()
}
}
}