37

I'm having this issue on one of my ads for an ios game

Here is my code, the odd thing is that if I add the device on the request.testDevices list it displays the demo banner, if I remove from testDevices, it does not show a real banner, but if I change my bundleIdentifier on XCODE, it shows a real banner,so I believe its something with my admob account, does anyone ever got something like it?

Its always failing with this error:

AdView didFailToReceiveAdWithError --------------------------- : Error Domain=com.google.ads Code=1 "Request Error: No ad to show." UserInfo={NSLocalizedDescription=Request Error: No ad to show., NSLocalizedFailureReason=Request Error: No ad to show.}

On my AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Use Firebase library to configure APIs
    [FIRApp configure];
    [[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:YES];
    // Initialize Google Mobile Ads SDK
    [GADMobileAds configureWithApplicationID:@"ca-app-pub-xx~xx"];
    /* other stuff here... */

}

on my rootViewController.m

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    bannerViewAdded = NO;
    interstitialViewAdded = NO;

   [self addBanner];
   // ..... more stuff here;
 }

- (void)addBanner{

    NSLog(@"CALL ADD BANNER ROOTVIEWCONTROLLER");

    if(!bannerViewAdded && ![MKStoreManager isFeaturePurchased:kFeatureAId]){

    NSLog(@"ADD BANNER ROOTVIEWCONTROLLER");
    CGSize size = [[CCDirector sharedDirector] winSize];


    // Create adMob ad View (note the use of various macros to detect device)
    if (IS_IPAD || IS_IPADHD) {
        bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeLeaderboard];
        bannerView.center = CGPointMake(size.width/2, (size.height-CGRectGetHeight(bannerView.frame)/2)-2);
    }
    else if (IS_IPHONE6) {
        bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
        bannerView.center = CGPointMake(size.width/2, (size.height-CGRectGetHeight(bannerView.frame)/2)-2);
    }
    else if (IS_IPHONE6P) {
        bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
        bannerView.center = CGPointMake(size.width/2, (size.height-CGRectGetHeight(bannerView.frame)/2)-2);
    }
    else {
        // boring old iPhones and iPod touches
        bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
        bannerView.center = CGPointMake(size.width/2, (size.height-CGRectGetHeight(bannerView.frame)/2)-2);
    }

    //[bannerView setBackgroundColor:[UIColor blueColor]];

    // Need to set this to no since we're creating this custom view.
    //bannerView.translatesAutoresizingMaskIntoConstraints = NO;

    // Note: Edit SampleConstants.h to provide a definition for kSampleAdUnitID
    // before compiling.

    // Replace this ad unit ID with your own ad unit ID.
    bannerView.adUnitID = @"ca-app-pub-xx/xx";
    bannerView.rootViewController = self;
    bannerView.delegate = self;
    [self.view addSubview:bannerView];


    GADRequest *request = [GADRequest request];
    //request.testDevices = @[ kGADSimulatorID ];
    //request.testDevices = @[  @"xx", @"xx"  , kGADSimulatorID ];

    [bannerView loadRequest:request];
    bannerViewAdded = YES;
    }

}

- (void)removeBanner {
  //admob
  if(bannerViewAdded){
      bannerViewAdded = NO;
      [bannerView removeFromSuperview];
      [bannerView release];
      bannerView = nil;
  }
  //No AdMOB
  if(localBannerAdded){
      localBannerAdded = NO;
      [localBannerButton removeFromSuperview];
      [localBannerButton release];
      localBannerButton = nil;
  }
}


- (void)addInterstitial{

    if(!interstitialViewAdded && ![MKStoreManager isFeaturePurchased:kFeatureAId]){
        NSLog(@"INIT INTERSTITIAL ROOTVIEWCONTROLLER");
        interstitialView =  [[GADInterstitial  alloc] initWithAdUnitID:@"ca-app-pub-xx/xx"];

        GADRequest *request = [GADRequest request];
        // Requests test ads on devices you specify. Your test device ID is printed to the console when
        // an ad request is made. GADBannerView automatically returns test ads when running on a
        // simulator.
        //request.testDevices = @[ kGADSimulatorID, @"xxx", @"xxx" ];
        [interstitialView loadRequest:request];
        [interstitialView setDelegate:self];

    }

}

- (void)adView:(GADBannerView *)gadBannerView didFailToReceiveAdWithError:(GADRequestError *)error{
    NSLog(@"AdView didFailToReceiveAdWithError --------------------------- : %@",  error);
    [self removeBanner];
    if(!localBannerAdded){
        CGSize size = [[CCDirector sharedDirector] winSize];
        localBannerButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
        localBannerButton.frame = CGRectMake(0.0, 0.0, 320.0, 50.0);
        [localBannerButton setTitle:@"DOWNLOAD MORE FREE GAMES" forState:UIControlStateNormal];
        localBannerButton.backgroundColor = [UIColor whiteColor];//[UIColor clearColor];
        [localBannerButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal ];
        [self.view addSubview:localBannerButton];

        [localBannerButton setCenter:CGPointMake(self.view.center.x,(size.height-CGRectGetHeight(localBannerButton.frame)/2)-2)];

        // Add Target-Action Pair
        [localBannerButton addTarget:self action:@selector(openAppStore:) forControlEvents:UIControlEventTouchUpInside];
        localBannerAdded = YES;
    }
 }
Gil Beyruth
  • 598
  • 1
  • 6
  • 11
  • My banner had 1 pixel distance from the game play area, so removing the banner from the game play screen, and asking for a new evaluation, fixed for me. The sad is it took almost 3 months to get an answer with the problem from Admob, I never got an email telling it, or any other contact from admob. Fixing was fast, after Apple approved the new version of my game, in 12 hours my banner was back. – Gil Beyruth Apr 02 '17 at 18:21
  • 1
    Almost two years later I'm still having the same problem. Really time I switched to another advertising platform. – newenglander Apr 14 '18 at 06:34
  • It working when app newly install on Simulator/ Devices. – Sourabh Kumbhar Mar 18 '20 at 00:47

20 Answers20

29

I just had this error today, the problem for me was simple, it was because the adUnitID is basically still new. I had to wait more than 2 hours after creating the adUnitID in order for the ads to be served.

If you have this error, and some of your adUnitIDs serve ads and some don't. You're highly likely having the same issue, and the only way to fix it is to wait.

Ibrahim
  • 6,006
  • 3
  • 39
  • 50
  • I just integrated with AdMob for ios mobile application. got app id and added configureWithApplicationID in appdelegate and initWithAdUnitID in viewcontroller request.testDevices = @[ @"some id"]; Here request.testdevices is not required? after read your answer i will wait try to wait for 2 hours. – kiran Jul 02 '18 at 13:41
  • 1
    any followup? did you try after 2 hours – ina Mar 16 '19 at 15:37
  • 14
    I'm waiting for 2 hours to pass since 2 weeks ago :). This doesn't worked for me. – Stefan Nov 07 '20 at 18:09
14

The ad server will return this message mainly because of the following:

  • There are no ads for your ad unit id.
  • Check whether your ad unit id is proper or not.
  • You will get the same error if either your banner width/height is 0.
  • Make sure that your adUnitID is perfect.

or check following links its may help you

https://groups.google.com/forum/#!topic/google-admob-ads-sdk/ioXU2nX9W28

AdMob Legacy Publisher ID not showing ads

Sangram Shivankar
  • 3,535
  • 3
  • 26
  • 38
  • I don't believe I been blacklisted, I have looked on my adsense account and I don't see anything there on the status. I sent a message so they can check if its blacklist, no response yet. I tried both, no lucky, I guess I will have to wait so some one from admob looks to my account, also I'm sure its not the size as it works if I change the bundle Identifier, and sure its not the adUnitID as it also show with different bundle. – Gil Beyruth Aug 24 '16 at 04:28
  • 8
    Setting the banner width/height fixed it for me. Hugely helpful! – mrgrieves Feb 16 '17 at 00:23
  • 1
    My banner had 1 pixel distance from the game play area, so removing the banner from the game play screen, and asking for a new evaluation, fixed for me. The sad is it took almost 3 months to get an answer with the problem from Admob, I never got an email telling it, or any other contact from admob. Fixing was fast, after Apple approved the new version of my game, in 12 hours my banner was back. – Gil Beyruth Jun 26 '17 at 15:36
  • This solved it for me, I had my banner height to 0 and if I receive an ad I put it to 50 but since it was 0, the delegate was always failing to get an ad. – Vasil Nunev Oct 09 '17 at 18:17
  • @mrgrieves did you have to contact google ad mobs support to get the issue resolved? I am having a similar issue, although I am not sure who to contact. – Pratik Baid Aug 18 '21 at 16:33
  • No, I didn't have to contact support. But that was in 2017, so things may have changed. – mrgrieves Aug 19 '21 at 23:06
12

I had just created a new account and seen that problem. When checking my account there was a message shown on the top of admob page: "Your ad units are not displaying ads because you haven't provided your account payments information yet.". Click on the button Fix it, fill the form and the ads will be shown within few hours

Tony
  • 1,551
  • 20
  • 21
6

Make sure you are using the test ad IDs when in a debug session.

https://developers.google.com/admob/ios/banner?hl=en-US

The easiest way to load test ads is to use our dedicated test ad unit ID for iOS banners: ca-app-pub-3940256099942544/2934735716

Ric Santos
  • 15,419
  • 6
  • 50
  • 75
5

I met this error too. Both my banner and interstitial ads failed with this error. I found that it is my mistake to change UserAgent globally, after I change UserAgent to default it works well.

monkjj
  • 51
  • 2
  • 1
    How to change UserAgent? – amar Sep 15 '17 at 06:35
  • I ran into issues serving both live and test ads, and it turned out it was because I was registering a "@UserAgent" key with my app's defaults plist using `[[NSUserDefaults standardUserDefaults] registerDefaults:@{@"UserAgent":@"MyUserAgent"}];`. Removing this key and setting UserAgent manually via `NSURLSessionConfiguration` and `WKWebViewConfiguration` where needed resolved the issue for me. – Nick Baicoianu Feb 17 '19 at 22:49
4

This error could happen if you have not setup your payment and billing information in your AdMob account. As per Admob after you setup the payment details, it can take up to 2 hours before it would be completely functional

Billing and Payments

Muhammad Nayab
  • 1,612
  • 14
  • 14
3

This solved my problem

  1. changing banner id to example id.
  2. run the app then .
  3. changing id back to production id.
Husam
  • 8,149
  • 3
  • 38
  • 45
3

For me, the reason why it started showing this is that I didn't have any payment methods set up on my AdMob account.

Once I have set this up, the error has disappeared and ads started showing instantly.

Hope this helps someone!

Dejan Atanasov
  • 1,202
  • 10
  • 13
3

If you are using your app in debug or testing mode make sure you are using test AppID and BannerID provided by google admob which would be as:-

Google Test AdMobID: ca-app-pub-3940256099942544~1458002511

Google Test BannerID ca-app-pub-3940256099942544/2934735716

Tejinder
  • 1,507
  • 19
  • 22
3

One possible reason is a Constraint bug.

you should guarantee your bannerView's constraint to other views is right

Nick is tired
  • 6,860
  • 20
  • 39
  • 51
yuanjilee
  • 429
  • 5
  • 16
3

I had the same issue when testing the sample application on my phone. I fixed with the following steps:

Reset Advertising identifier on iPhone 6, Go to:

Settings -> Privacy -> Advertising -> Reset Ad identifier

Ankur Aggarwal
  • 2,210
  • 2
  • 34
  • 39
Rawand Saeed
  • 795
  • 10
  • 13
3

After create adUnitID, Wait for 1-2 hours and then try it out.

Because I had the same issue and it gets solved just after 1-2 hours.

Enjoy coding :)

Sunil Targe
  • 7,251
  • 5
  • 49
  • 80
2

In my case, ads are working fine but suddenly it stop showing ad with error: No ad to show. I noticed console is throwing error about test device identifier. Somehow the test device identifier get changed. I don't know how it happen, may be due to Xcode upgrade. I am not sure. But once I changed the test device identifier, it start working again.

Khushneet
  • 854
  • 9
  • 10
1

Do not make any modifications in code if this error pops, just wait about 3-4 days. Google takes time to send adds for new accounts

achinthaishane
  • 77
  • 1
  • 2
  • 9
0

Make sure not to make an other variable of GADBannerView. Use one variable in every controller by making it global and just change unit id.

e.g this line should be out of any controller (global)

var bannerView: GADBannerView!

then use it wherever you want and just change id accordingly

bannerView.adUnitID = "ca-app-exampleid-abcabc938-4e8"
0

I was used to init the banner like this:

adBannerView = GADBannerView()

and it was working.

I can't say precisely from which AdMob library version, but suddently the banner wasn't show anymore.

Init the banner with the size as parameter, fixed the problem:

adBannerView = GADBannerView(adSize: kGADAdSizeBanner)

Lubbo
  • 1,030
  • 1
  • 10
  • 18
0

I solve this by adding request.testDevice = @[@"xxxxxxxxxxxx"] before load request.(I get this tip and test device number from console)

Randall Wang
  • 1,007
  • 3
  • 10
  • 24
0

The best way I think should be used the test ad Ids from the integration guide from Google, after that change to your Ad Ids when it goes live.

Peter Nguyen
  • 61
  • 1
  • 3
0

I faced with this issue even with google test ad units.

In my scenario, problem was, I modified the WkWebView UserAgent directly without concatenating with the real one.

I had to change from;

static func arrangeUserAgent() {
    let webView = WKWebView()
    webView.evaluateJavaScript("navigator.userAgent") { (result, error) in
        webView.customUserAgent = "Some Awesome User Agent"
        let dictionary = Dictionary(dictionaryLiteral: ("UserAgent", webView.customUserAgent!))
        UserDefaults.standard.register(defaults: dictionary)
    }
}

to;

static func arrangeUserAgent() {
    let webView = WKWebView()
    webView.evaluateJavaScript("navigator.userAgent") { (result, error) in
        let mergedUserAgent = "\(result ?? "") Some Awesome UserAgent"
        webView.customUserAgent = mergedUserAgent
        let dictionary = Dictionary(dictionaryLiteral: ("UserAgent", mergedUserAgent))
        UserDefaults.standard.register(defaults: dictionary)
    }
}

Had rough times to find the problem. Be careful with the UserAgent you change.

Happy coding.

Onur Şahindur
  • 492
  • 8
  • 18
-1

In the Settings of your iOS device: Settings > Privacy > Advertising: Turn on and then turn off "Limit Ad Tracking" ("Reset of Ad Identifier" doesn't always help. Try "Reset of Ad Identifier" first and comment if this action doesn't help you). But! It will help only get ads on your own device and will not solve the problem that matching rate of your ad is low.