Search code examples
iosswiftxcodeadmobtestflight

AdMob banner shows in Simulator but not on device/TestFlight


I'm using AdMob for banner ads in an app. The banner ads show up on the Simulator but not when I run it on an iPhone device via connected cord or TestFlight.

This is my code for running it on a real device:

let request = GADRequest()
bannerView.adUnitID = realAdUnitID
bannerView.rootViewController = self
bannerView.delegate = self
bannerView.load(request)

Am I missing something?

I've tried to look at other questions but nothing has worked for me yet that has been suggested.

Thanks!


Solution

  • First of all, do you running the debug or the release version? If you run your app in the debug mode, add the device id (you can find it in the console) to the testDevices array:

    let request = GADRequest()
    request.testDevices = [kGADSimulatorID,  // All simulators
                           "2077ef9a63d2b398840261c8221a0c9b"];  // Sample device ID
    

    Read more about test ads in AdMob Documentation

    And the second thing you should consider, that AdMob may not provide enough fill rate for your ads. Especially if the app is new, it can take some time while traffic will be analysed, before the service will provide your some ads. Consider this, if your testing your app in release mode.