Search code examples
iosiphoneswiftdebuggingiad

iAd Banner swift , after i added iAd the game started crash


i developed this game , and it works fine like i want it to do , but after i added the iAd banner , when i start the game it would run normally for like 10 sec. and the it zoom in and make every thing very large and then it would give me this error :

Shapes#2[75422:7643415] [AppDeveloper] ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=1 "Service session terminated." UserInfo=0x7fdb09f5b1e0 {ADInternalErrorCode=1002, NSLocalizedDescription=Service session terminated.}

Solution

  • You're missing your didFailToReceiveAdWithError function. You can copy and paste this code in, just make sure you iAd banner matches what is in your project:

    func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
        println("Error failed to load. Probably due to network connection.")
        self.adBannerView.hidden = true//hide the banner
    }
    

    The problem is probably the iAd banner cannot load and you don't have the didFailToReceiveAdWithError function which runs when the banner can't load. If the banner doesn't load, and there's no function to handle this, the compiler will complain. P.S. You may want to insert this function too. This one is the opposite of didFailToReceiveAdWithError, it runs when the banner can load.

    func bannerViewDidLoadAd(banner: ADBannerView!) {
        println("Banner did load.")
        self.adBannerView.hidden = false//show banner
    }
    

    You can find more info about iAd here.