0

I followed the implementation Revmob guide to use interstitial advertisement for my game, but when I launch my game I get an error:

2015-01-13 15:02:20.406 basisTest[38021:42032052] [RevMob] Starting RevMobAds
2015-01-13 15:02:21.057 basisTest[38021:42032052] [RevMob] Warning: RevMob session was not started
fatal error: unexpectedly found nil while unwrapping an Optional value

the error is pointing to this line in my appdelegate:

func applicationDidBecomeActive(application: UIApplication) {
    RevMobAds.session().showFullscreen();
}

my viewdidload method in my GameViewController:

override func viewDidLoad() {
    super.viewDidLoad()
    let completionBlock: () -> Void = {
        // do something when it successfully starts the session
    }
    let errorBlock: (NSError!) -> Void = {error in
        // check the error
        println(error);
    }
    RevMobAds.startSessionWithAppID("54b515b6b1abae000f771a71",
        withSuccessHandler: completionBlock, andFailHandler: errorBlock);
}

I followed the guide exactly and added all frameworks to my project and changed my build setting as expected.

What am I doing wrong?

sdd
  • 889
  • 8
  • 29

1 Answers1

1

Add RevMobAds.session().showFullScreen() to let completionBlock instead of your app delegate

override func viewDidLoad() {
super.viewDidLoad()
let completionBlock: () -> Void = {
    // do something when it successfully starts the session
    RevMobAds.session().showFullScreen()
}
let errorBlock: (NSError!) -> Void = {error in
    // check the error
    println(error);
}
RevMobAds.startSessionWithAppID("54b515b6b1abae000f771a71",
    withSuccessHandler: completionBlock, andFailHandler: errorBlock);
}

Also say you want to add it when transitioning scenes. Put the entire block in your Game Scene transition location.

I did that because I don't want the ad to open when the app opens and rather when the player loses the game and a scene is switched

Bryan N
  • 111
  • 4
  • I tried doing the same thing, but received a "Apple Mach-O Linker" error. Any thoughts? I already read the RevMob Swift implementation and added my session to the completion block. Still no success. – mprithibi Jun 27 '15 at 14:57