Need Help Integrating Interstitial ads in Spritekit iOS Game

后端 未结 1 2040
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-16 11:10

I am making a game using Xcode and SpriteKit, I am integrating ads using admob and have all of the code working for the banner ads and have been able to get the interstitial

相关标签:
1条回答
  • 2021-01-16 11:30

    In your GameViewController, setup a notification observer in viewWillLayoutSubviews like so:

    override func viewWillLayoutSubviews() {
    
        NotificationCenter.default.addObserver(self, selector: #selector(self.showAd), name: NSNotification.Name(rawValue: "showAd"), object: nil)
    
    }
    

    Then in your GameScene, call this when you want the function in GameViewController to be run:

    NotificationCenter.default.post(name: NSNotification.Name(rawValue: "showAd"), object: nil)
    

    Keep in mind that you need to have a function to be called inside your GameViewController. showAd is just a placeholder for whatever function you want to be run inside your GameViewController.

    Hopefully this helps!

    0 讨论(0)
提交回复
热议问题