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
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!