2

In my gameviewcontroller I can present the interstitial like this:

    var request = GADRequest()
    request.testDevices = [GAD_SIMULATOR_ID];
    var interstit = GADInterstitial()
    interstit = interstit2
    interstit.adUnitID = "ca-app-pub-3940256099942544/2934735716"
    interstit.loadRequest(request)
    println("req loaded admob")

if interstit.isReady{
       interstit.presentFromRootViewController(self)
       request()
    }

But I want to call the same interstitial in the GameScene(SKScene), and presentfromrootviewcontroller is not working in there, what is the solution?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
sdd
  • 889
  • 8
  • 29

1 Answers1

1

That's the answer in Swift:

let currentViewController:UIViewController=UIApplication.sharedApplication().keyWindow!.rootViewController!

interstitial.presentFromRootViewController(currentViewController)
Oscar Falmer
  • 1,771
  • 1
  • 24
  • 38