Admob Banner doesn't show - ios

I want to implement Admob into an app for iPad in landscape mode, I followed step by step tutorial for admob, on adding advertising to the app. I added all the frameworks and requirements given to work correctly.
I can't see the banner. I tried both the simulator and on the device itself. According to the following link it seems that:
"Test ads are not supported on iOS 6 devices; use the simulator instead"
The compilation is correct without issues.
I changed the background of the red banner, and I moved all the views that would hide the banner, but still I couldn't see it. Inside the viewDidLoad method, I have placed it in different positions
From Google admob statistics I see that increase requests, this I don't understand. O___O
The AdMob SDK is the latest.
I appreciate any help.
My code:
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height -
GAD_SIZE_728x90.height,
GAD_SIZE_728x90.width,
GAD_SIZE_728x90.height)];
bannerView_.adUnitID = MY_BANNER_UNIT_ID;
bannerView_.delegate = self;
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[self.view bringSubviewToFront:bannerView_];
bannerView_.backgroundColor= [UIColor redColor];
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:
#"6A1E19F-xxxxx-xxxx-xxxxDF38593ECBD" ,
#"9bc75xxxxxxxxxxxxxxx762de7c79fb",
nil];
request.testing = YES;
[bannerView_ loadRequest:request];

try this
request.testDevices = [NSArray arrayWithObjects:#[#"GAD_SIMULATOR_ID"], nil];
[yourbannerview loadRequest:request];
and delete request.test, is disabled now :/

Related

Is there any delegate methods to hide google Ads without add button to hide Ad Objective c?

I am working on Bottom Banner Ad in table view.It's working fine but client wants to delete the ad when they don't need.So How can I do this???can you give me a suggesstion or code when i try to delete tha ad it's not deleted see my code and image below:
GADRequest *request = [GADRequest request];
self.bannerview = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
self.bannerview.adUnitID = #"ca-app-pub-4719922286387557/3468269154665";
self.bannerview.rootViewController = self;
[self.navigationController.toolbar addSubview:self.bannerview];
[self.bannerview loadRequest:request];

Unable to hide admob banner programatically in iOS

I seem to be unable to hide an Admob banner during my game, using the following method to show;
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
bannerView_.delegate=self;
bannerView_.adUnitID = ADMOB_ID;
bannerView_.rootViewController = self.viewController;
[viewController.view addSubview:bannerView_];
GADRequest *request =[GADRequest request];
[bannerView_ loadRequest:request];
When trying to hide it, even to test it I have hooked it up to a button
- (void)removeBanner{
NSLog(#"should be removing banner");
[bannerView_ setHidden:YES];
[bannerView_ removeFromSuperview];
}
I have tried both of the above options inside removeBanner, however none of them make the banner disappear?
A couple of things to check
Do you call the first function more than once? Put an assert that bannerView_ is not already set. If it were called more than once, you'd only be removing the last one.
Is bannerView_ somehow nil in removeBanner?
edit: probably you should set bannerView_ to nil after you remove it (but I doubt that would matter). Also, you could call setNeedsDisplay on viewController.view (and then displayIfNeeded to force it to happen immediately)

AdMob ad test banner NEVER load in mediation

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
self.iAdbanner.hidden=YES;
_bannerView=[[GADBannerView alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
self.bannerView.adUnitID=#"UNIT_ID";
self.bannerView.rootViewController=self;
[self.view addSubview:self.bannerView];
self.bannerView.delegate = self;
_bannerView.hidden=NO;
GADRequest *request =[GADRequest request];
request.testDevices= #[ GAD_SIMULATOR_ID ];
[self.bannerView loadRequest:request];
}
Only the iAd test banner loads. However, when the iAd test banner fails, I don't understand why AdMob test banner never loads in simulator and device. Didn't I implement the correct code for AdMob test banner to fill the spot of iAd banner failures?
You're better off creating a Singleton class Ad banner to share a single ad on multiple view controllers.
Are you setting the size you are requesting? Something like:
self.bannerView.adSize = kGADAdSizeSmartBannerPortrait;

Admob showing ads in simulator but not in device

This is the code that I am currently using to show some ads on my device. But it doesn't seem to work as of now. Need some guidance on what could be going wrong here.
self.adBanner = [[GADBannerView alloc]
initWithFrame:CGRectMake(0,468,320,50)];
self.adBanner.adUnitID = #"a153b29f919d822";
self.adBanner.delegate = self;
[self.adBanner setRootViewController:self];
[self.view addSubview:self.adBanner];
//self.adBanner.center = CGPointMake(self.view.center.x, self.adBanner.center.y);
GADRequest *r = [[GADRequest alloc] init];
r.testing = YES;
[self.adBanner loadRequest:r];
Thanks.
If you have recently setup up your account in Google AdMob, it is going to take sometime for the ads to start appearing on the device.
But you can try setting testDevices in your GADRequest. The device Id will be being printed out in your console by the AdMob SDK.
Then add the below code.
r.testDevices = #["test_device_id"];

self.addSubView not working on iPad

I have an app that attempts to retrieve an iAd and if is unsuccessful loads an AdMob ad. It works perfectly on iPhone but when run on iPad I get a continuous loop that prevents the app from loading. Here's some code:
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
#try {
NSLog(#"Ad Error, looking for AdMob Ad...");
// Create a view of the standard size at the bottom of the screen.
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height -
GAD_SIZE_320x50.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];
// I know the banner size is incorret for iPad but it's only supposed to run
// on iPad in compatibility mode and changing doesn't help
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = #"XXXXXXX";
// 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_];
GADRequest *admobRequest = [GADRequest request];
admobRequest.testDevices = [NSArray arrayWithObjects:
GAD_SIMULATOR_ID,
nil];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest: admobRequest];
[iAdBanner setHidden: YES];
[bannerView_ setHidden: NO];
}
#catch (NSException *e) {
NSLog(#"Exception: %#", e);
}
#finally {
}
}
The NSLog prints out continuously and the app doesn't load.
012-02-24 21:58:38.991 TrophyConverter Free[2948:15e03] Ad Error, looking for AdMob Ad...
2012-02-24 21:58:38.992 TrophyConverter Free[2948:15e03] Ad Error, looking for AdMob Ad...
2012-02-24 21:58:38.994 TrophyConverter Free[2948:15e03] Ad Error, looking for AdMob Ad...
Has anyone else experienced this? How do I over come it? I've managed to use a bool to stop the continuous log printing and load the app but no Ad is shown.
EDIT:
The issue completely disappears when I remove this line
[self.view addSubview:bannerView_];
which isn't helpful since this is the part that adds the AdMob view.
I've also tried changing the build target to be a universal app rather than a iPhone app. This fixes the problem but I don't want it to be a universal app and I have no layouts created for it.
I couldn't find a fix for this in the end so I basically added a bool that was switched once one fail had been made. Then no ad would be added if the check had been done and not already worked.

Resources