1

I think that I setup the code for the Banner Ad correctly but the is is not showing up when I run the application in the simulator or on my iPhone.

@IBOutlet var BannerAD: GADBannerView!

@IBOutlet var ScoreLabel: UILabel!

var taps = Int(){
    didSet {
        if taps == 330 {
            print("You have reaches 5 taps !!")
        }
    }
}


override func viewDidLoad() {
    super.viewDidLoad()
    //BannerView
    let request = GADRequest()
    request.testDevices = [kGADSimulatorID]
    BannerAD.delegate = self
    BannerAD.adUnitID = "ca-app-pub-1469592343938512/3073825187"
    BannerAD.rootViewController = self
    BannerAD.loadRequest(request)

2 Answers2

0

Add this line to your viewDidLoad (but before you make the ad request):

BannerAd = GADBannerView(adSize: kGADAdSizeBanner)

When you do this, you might need to set the frame of your ad like so:

BannerAd.frame = CGRect(x: 0, y: 0, width: 320, height: 50)
Nik
  • 1,664
  • 2
  • 14
  • 27
  • When I paste in the second line of code Xcode shows me an error (arguments width, height, x, y do not match any available overloads) – Juli IchSelber Sep 25 '16 at 18:48
  • Does it work without the second line? I modified the second line too – Nik Sep 25 '16 at 18:50
  • No it is unfortunately not working. There is no error anymore but it does not work nevertheless. – Juli IchSelber Sep 26 '16 at 08:48
  • 1
    @JuliIchSelber What was the original error? You didn't say anything about an error. Also, define: "It's not working" – Nik Sep 26 '16 at 21:06
0

Try to implement GADBannerViewDelegate delegate methods to check if app is receiving ads:

func adViewDidReceiveAd(_ bannerView: GADBannerView!) {
   print("ad received")
}

func adView(_ bannerView: GADBannerView!, didFailToReceiveAdWithError error: GADRequestError!) {
   print("fail to receive ad with error: \(error.localizedDescription)")
}
phantom_2
  • 543
  • 7
  • 14