Show Admob Interstitial ads between scenes in Swift SpriteKit

后端 未结 2 1439
眼角桃花
眼角桃花 2021-01-14 04:58

I would like to know how to set up Admob Interstitial ads when I present my GameOverScene. What should I do to show the ads only sometimes when the game gets over? And how d

2条回答
  •  忘掉有多难
    2021-01-14 05:47

    why dont you use NSNotificationCenter or delegates to call showInterstitial().

    For example

    In gameViewController add this in viewDidLoad

     NSNotificationCenter.defaultCenter().addObserver(self, selector: "showInterstitial"), name:"showInterAdKey", object: nil);
    

    and when you want to show the ad from your scenes you use

     NSNotificationCenter.defaultCenter().postNotificationName("showInterAdKey", object: nil)
    

    You could also use something like the helper I posted on github which makes this even easier and your ViewController stays clean https://github.com/crashoverride777/Swift-2-iAds-and-AdMob-Helper

提交回复
热议问题