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;
}
}
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.
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
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
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.
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
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
This solved my problem
changing banner id to example id.
run the app then .
changing id back to production id.
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!
One possible reason is a Constraint bug.
you should guarantee your bannerView's constraint to other views is
right
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
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 :)
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
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.
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
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"
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)
I solve this by adding request.testDevice = #[#"xxxxxxxxxxxx"] before load request.(I get this tip and test device number from console)
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.
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.
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.
I have integrated AppLovin in AdMOb mediation. And followed all the steps mentioned in AppLovin docs.
When I run the application to show AppLovin videos with below code,
GADInterstitial* interstitialVideo = [[GADInterstitial alloc] initWithAdUnitID:#"ca-app-pub-xxxxxxxxxxxx"];
interstitialVideo.delegate = self;
GADRequest *request = [GADRequest request];
// Requests test ads on test devices.
request.testDevices = #[ testDeview ];
[interstitialVideo loadRequest:request];
if ([interstitialVideo isReady]) {
[interstitialVideo presentFromRootViewController:self];
}
I am getting below exception,
[2604:1732410] -[GADMAdapterAppLovinRewardBasedVideoAd initWithGADMAdNetworkConnector:]: unrecognized selector sent to instance 0x1283d7570
2016-04-20 16:14:32.100 [2604:1732410] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GADMAdapterAppLovinRewardBasedVideoAd initWithGADMAdNetworkConnector:]: unrecognized selector sent to instance 0x1283d7570'
** First throw call stack:
I tried adding -ObjC -all_load to other linker flags but still i get same exception.
Please let me know if any one know whats wrong here.
Finally I fixed the issue.
I need to use below code instead of above code(as mentioned in question)
//Initialize
[GADRewardBasedVideoAd sharedInstance].delegate = self;
[[GADRewardBasedVideoAd sharedInstance] loadRequest:[GADRequest request]
withAdUnitID:#"ca-app-pub-xxxxxxxxxxxx"];
//To show add
if ([[GADRewardBasedVideoAd sharedInstance] isReady]) {
[[GADRewardBasedVideoAd sharedInstance] presentFromRootViewController:self];
}
After above changes I started getting the AppLovin videos.
For more details check link https://developers.google.com/admob/ios/rewarded-video#request_rewarded_video
Can you verify that you've added our most recent AdMob adapters to your project? It looks like you're trying to use interstitials but getting a rewarded video error. Did you configure a rewarded video ad unit in your AdMob dashboard instead of an interstitial by mistake or vice versa?
Feel free to contact us at support#applovin.com for further assistance.
I am trying to integrate AdMob's interstitial ads into my iOS, but even though everything seems okay, I am not getting any of the interstitial delegate methods (including failure too) fired. I have set my ad as an interstitial Ad and I have my Ad unit ID correct. Here is my code:
GADInterstitial *interstitialAd = [[GADInterstitial alloc] init];
interstitialAd.adUnitID = AD_UNIT_ID;
interstitialAd.delegate = self;
GADRequest *adRequest = [GADRequest request];
#if DEBUG
adRequest.testDevices = #[ #"9ab869b041b0e1d5a362be13c99eb69a" ];
#endif
[interstitialAd loadRequest:adRequest];
I've got a breakpoint at the above code and it is firing. Then, at the same class, I've got the delegate methods implemented:
-(void)interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error{
loadedAd = nil;
}
-(void)interstitialDidReceiveAd:(GADInterstitial *)ad{
loadedAd = ad;
[self presentAdIfAppropriate];
}
However, neither of these methods are being called, even after waiting for minutes. I have a stable internet connection on my device, and the connection timeout is set as 4 seconds at AdMob website. Why doesn't my ad load?
You should keep a strong reference (in the class scope) on the interstitial ad object as it will be probably released after you load the request (as it is defined in the local scope of your request method).
Also, make sure you've set up and are referencing an adUnitID for the specific iOS app you're testing (under Monetize on admob.com). Just using the adUnitID from the sample app, or one from your app on a different platform will not work. The symptom is that none of the delegate methods will fire, not even didFailToReceiveAdWithError.
Hi After I add GADBannerView, the delegate bannerViewDidLoadAd notice that received new ad, why nothing be showed on the view?
botBanner = [[GADBannerView alloc] initWithAdSize:GADAdSizeFullWidthPortraitWithHeight(50)];
botBanner.adUnitID = kGADKey;
botBanner.delegate = self;
botBanner.rootViewController = self;
[_adBannerBotView addSubview:botBanner];
adRequest = [GADRequest request];
// Make the request for a test ad. Put in an identifier for
// the simulator as well as any devices you want to receive test ads.
adRequest.testDevices = [NSArray arrayWithObjects:#"<I add my device id>", GAD_SIMULATOR_ID, nil];
[botBanner loadRequest:adRequest];
I found the answer, it's really stupid.
Post this for someone that also looking for this stupid problem.
If you want to received ad on your device, DO NOT put your device ID in the adRequest.testDevices
I have setup a basic application as a test, using the AdMob Mediation service.
- (void)viewDidLoad {
[super viewDidLoad];
// Create a view of the standard size at the top of the screen.
// Available AdSize constants are explained in GADAdSize.h.
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = kAdMobPublisherID;
// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];
GADRequest *request = [GADRequest request];
// Make the request for a test ad. Put in an identifier for
// the simulator as well as any devices you want to receive test ads.
request.testDevices = [NSArray arrayWithObjects:
#"4D047EB9-A3A7-441E-989E-C5437F05DB04",
#"YOUR_DEVICE_IDENTIFIER",
nil];
}
I am receiving these errors when the application fails to receive an Ad. I believe iAd sends errors quite a bit during test iAd adverts.
[AppDeveloper]: ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=4 "The operation couldn’t be completed. Application has iAd Network configuration error" UserInfo=0x9fd8d20 {ADInternalErrorCode=4, ADInternalErrorDomain=ADErrorDomain, NSLocalizedFailureReason=Application has iAd Network configuration error}
The error is due to not implementing the didFailToReceiveAdWithError. The issue I have is how to implement this method.
I have looked in the iAd Progamming Guide : iAd Prog Guide
This suggests setting up a method like this...
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
However, as my code is not implementing the iAd network directly, it is setup using a mediation service. I am unsure how to change the above method to work.
Because the AdMob framework handles the ad display (even if mediated to other ad sources like iAd), you only need to implement the handling of AdMob banners. If the AdMob framework displays an iAd through mediation, it'll encapsulate it and present it to you like any regular AdMob banner.
Therefore you just need to set the delegate of the bannerView to receive events from the AdMob framework, e.g. let your view controller implement the GADBannerViewDelegate protocol and use it as the delegate):
#interface MyViewController : UIViewController <GADBannerViewDelegate>
...
in your viewDidLoad method:
bannerView_.delegate = self;
You can then add various methods to handle ad events, like
- (void)adView:(GADBannerView *)bannerView didFailToReceiveAdWithError:(GADRequestError *)error;
which is called when no ad could be requested. Also useful:
- (void)adViewDidReceiveAd:(GADBannerView *)bannerView;
which is called whenever an ad was received successfully. This method is usually used to slide in the ad banner. The passed bannerView is always of class GADBannerView, but it has a property mediatedAdView that contains the actual ad to display (which could be an iAd banner).
Btw, you're preparing an ad request in your code, but you dont't actually use it for loading an ad. You probably also want to move down the loadRequest: call and use the prepared request:
[bannerView_ loadRequest:request];
There's more about the GADBannerViewDelegate methods in the AdMob SDK docs at: https://developers.google.com/mobile-ads-sdk/docs/admob/intermediate.
I think you missed to add line:
bannerView_.delegate = self;