0

Here's the error/ warning I get: 2016-01-20 13:21:58.375 TEst[11131:3816829] [AppDeveloper] ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=7 "Ad was unloaded from this banner" UserInfo={ADInternalErrorCode=7, NSLocalizedFailureReason=Ad was unloaded from this banner, ADInternalErrorDomain=ADErrorDomain}

Here's what my code looks like: Code for ad banner

Am I missing something? ( I attached my iAd banner as an outlet and called it adBanner).

2 Answers2

2

You need to add something like adBanner.delegate = self and implement the function didFailToReceiveAdWithError:

Witterquick
  • 6,048
  • 3
  • 26
  • 50
0

As the user above said you need to call

adBanner.delegate = self

in your ViewDidLoad and implement the delegates in your scene to handle the different banner states. Probably easiest to use an extension to keep the code clean.

 //Delegates AdMob Banner
extension GameScene: GADInterstitialDelegate {

 func adViewDidReceiveAd(bannerView: GADBannerView!) {
    print("AdMob banner did load, showing")

    // animate banner into your view/scene
}

func adViewWillPresentScreen(bannerView: GADBannerView!) {
    print("AdMob banner clicked")

    // pause game if needed as ad was pressed
}

func adViewDidDismissScreen(bannerView: GADBannerView!) {
    print("AdMob banner closed")

   // banner closed
}

func adView(bannerView: GADBannerView!, didFailToReceiveAdWithError error: GADRequestError!) {
    print("AdMob banner error")

    // handle error, hide from view etc
 }
}

I made an ads helper specifically for spriteKit, you might find it useful https://github.com/crashoverride777/Swift2-iAds-AdMob-CustomAds-Helper

crashoverride777
  • 10,581
  • 2
  • 32
  • 56