在SpriteKit中显示插页式广告AdMob广告

时间:2017-01-22 23:31:05

标签: ios swift xcode admob interstitial

我正在尝试在我的应用中展示广告。下面的代码是我现在在import UIKit import SpriteKit import GoogleMobileAds // Network Ads import AdSupport class GameViewController: UIViewController, GADBannerViewDelegate, GADInterstitialDelegate { var adBannerView: GADBannerView! var myAd = GADInterstitial() let request = GADRequest() override func viewDidLoad() { super.viewDidLoad() let scene = GameScene() let skView = self.view as! SKView scene.scaleMode = .aspectFill scene.size = skView.frame.size skView.presentScene(scene) NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.loadAndShow), name: NSNotification.Name(rawValue: "loadAndShow"), object: nil) } func loadAndShow() { myAd.setAdUnitID("ca-app-pub-3940256099942544/4411468910") myAd.delegate = self myAd.load(request) } func interstitialDidReceiveAd(_ ad: GADInterstitial) { if (self.myAd.isReady) { myAd.present(fromRootViewController: self) } } } 中使用的代码:

myAd.setAdUnitID("...")

该代码显示此测试广告: Image here

我进入AdMob网站并使用广告格式创建了“新广告单元”:非页内广告。然后我获得了广告单元ID ,但是当我在我的代码中的int logicalShift(int x, int n) { int mask = x>>31<<31>>(n)<<1; return mask^(x>>n); } 中放入广告单元ID 时,我的应用中没有显示任何广告一点都不。

Click here for image of my AD UNIT

我在这里做错了什么想法?

0 个答案:

没有答案