AdMob not showing ads in iOS simulator - iphone

I am trying to use AdMob on an app (built for iOS 4.0)
I've added the sample code available in the tutorial http://code.google.com/mobile/ads/docs/ios/fundamentals.html which is the following (I've changed the adUnitID):
// 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)];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = #"XYZ";
// 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_];
[self.view bringSubviewToFront:bannerView_];
GADRequest * request = [GADRequest request];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:request];
Doing this nothing happens, no ad is shown and the number of requests in my AdMob app page increase erratically (i.e.: I can't seem to notice a pattern), but the most important is no ad is shown.
If I add the following code:
GADRequest * request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:
GAD_SIMULATOR_ID, // Simulator
nil];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:request];
I get the "Success! You are now ready to travel through the App Galaxy" default banner, but only this one.
So my questions are:
Aren't the sample code enough to show ads? Why I never see an ad with the sample code?
As far as I understood, requests mean the number of times my app asked for an ad to be shown. I also understood that not every request is replied with an ad (otherwise the fill rate would be 100%), but still, I NEVER saw an ad, what am I doing wrong?
Thanks in advance.

GADBannerView *bannerView = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height -
GAD_SIZE_320x50.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];//Set Position
bannerView.adUnitID = #"12331255421245";//Call your id
// 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];//Your attempt to add bannerview
// Initiate a generic request to load it with an ad.
[bannerView loadRequest:[GADRequest request]];

I set all above methods. Ad banner looks properly in Device but not showing ad in Simulator.
I set device Id as GAD_SIMULATOR_ID.but it doesnt work. Its delegate methods are not being called. !!

Try it in the device. Apps in simulator don't show Admob ads.

Related

Admob not working at AppStore

I have implemented Ad mobs in my iPhone app. The app is receiving ads in simulator and device while debugging. but when i upload it to app store it is not receiving any.
I'm using this piece of code
-(void)showAds{
self.adBanner = [[[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner
origin:origin]autorelease];
self.adBanner.adUnitID = #"abcdef1234567890.";
self.adBanner.delegate = self;
[self.adBanner setRootViewController:self];
[self.view addSubview:self.adBanner];
GADRequest *request = [GADRequest request];
[self.adBanner loadRequest:request];
}
I dont know what mistake m I making ?? any help ?
It looks like you have a period at the end of your adUnitID. Are you sure that should be there?

How to implement AdMob in Phonegap

I have a phonegap application and im trying to implementing Admob.
I'm using phonegap version 1.4.1 and I am using this site as my reference : http://iphone.keyvisuals.com/iphonedev/implementing-admob-ads-in-a-phonegap-project-for-ios-no-plugins-required/
My code is as follows:
(void)webViewDidFinishLoad:(UIWebView *)theWebView
{
bannerView_ = [[GADBannerView alloc]init];
[bannerView_ setDelegate:self];
[bannerView_ setFrame:CGRectMake(0, 0, 320, 50)];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = MY_BANNER_UNIT_ID;
// 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.viewController;
[self.viewController.view addSubview:bannerView_];
// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];
// only valid if AdGap.plist specifies a protocol to handle
if(self.invokeString)
{
// this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready
NSString* jsString = [NSString stringWithFormat:#"var invokeString = \"%#\";", self.invokeString];
[theWebView stringByEvaluatingJavaScriptFromString:jsString];
}
return [ super webViewDidFinishLoad:theWebView ];
}
Everything is fine, but when I am running the application, no ads are being displayed.
Please make sure that your "theWebView" object finishes its webload. And that the bannerView_ is a registered property of your object.
Also, I hope you just put in "MY_BANNER_UNIT_ID" to hide your banner unit id.
Check up with your admob settings if the banner unit id is correct.
And finally, please use a iphone proxy like Charles or similar to validate that the call goes out as it should.
Phonegap has been upgraded. It support new features. just add this code in your config.
<gap:plugin name="com.admob.plugin" version="1.0.0" source="plugins.cordova.io"/>

admob click after return it wrong layout

I use cocos2d combined with AdMob , nomarl my app work great, but after hit the advertising and return the game, it wrong layout, my game is landscape!
Things changes after AdMob is involved. AdMob has a AD type "movie". After clicking the ad, it popups a full screen mode, and play a movie, and then back to the game. The game changes, originally, it is landscape mode, and after back from ad, it seems to be portrait mode, and the game is scaled, everything looks bad. I have tried to update the view controller / CCDirector after back from ad, but it doesn't work.
A workaround found: just rotate the device to the counterpart landscape mode and everything goes well again.
Just wonder if there is any way to prevent telling customers rotate it manually?
Have you encountered this before?
_viewController = [[UIViewController alloc] init];
_viewController.view = [[CCDirector sharedDirector] openGLView];
_admobView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
_admobView.adUnitID = ADMOB_PUBLISHER_ID;
_admobView.delegate = self;
GADRequest *request = [GADRequest request];
request.testing = YES;
[_admobView setRootViewController:_viewController];
[_admobView loadRequest:request];
[_viewController.view addSubview:_admobView];
I had a similar issue before, and the cause was that I created a new UIViewController and set it as rootViewController for AdMob view - just like what you are doing:
_viewController = [[UIViewController alloc] init];
_viewController.view = [[CCDirector sharedDirector] openGLView];
...
[_admobView setRootViewController:_viewController];
This leads to layout problems when returning from some kinds of advertisement. What I am doing now in my app is like:
adMobView.rootViewController = [RootViewController sharedInstance];
[[[CCDirector sharedDirector] openGLView] addSubview:adMobView];
where [RootViewController sharedInstance] is a class method which returns the only instance of RootViewController in the app. For details please refer to my answer to another question: https://stackoverflow.com/a/10222956/1241690
(For cocos2d 2.x, the second line should be:
[[[CCDirector sharedDirector] view] addSubview:adMobView];
)

Why is my AdMob code leaking in my iphone app?

I have included AdMob in my iphone app. I have the following code in my viewDidLoad method:
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
0.0,
320,
50)];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = ADMOB_BANNER_UNIT_ID;
// 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.
GADRequest *r = [[GADRequest alloc] init];
r.testing = YES;
[bannerView_ loadRequest:r];
[r release];
This leaks. When I comment out the second last line ( [bannerView_ loadRequest:r]; ), the leak disappears. The only thing I changed in this code from the example provided by Google was to introduce the variable r so I could put AdMob in testing mode. In the code supplied by Google, bannerView_ is released by viewDidUnload. I looked for the loadRequest method but all I found was a definition in the GADBannerView.h file. As far as I can tell, there is no GADBannerView.m file, which seems weird in itself. Anyway, any tips would be much appreciated.
Thanks,
John
Why don't you use this AdMediator - it is very simple to configure and you don't have to worry about AdMob and iAds (if you want to use it) :
will swap in AdMob ads if no iAds are
available.
Are you releasing bannerView_ in your dealloc method or somewhere else appropriate ?
Instead of:
GADRequest *r = [[GADRequest alloc] init];
You could try:
GADRequest *r = [GADRequest request];

iPhone - AdMob not appearing. Using sample code

I'm trying to add AdMob to my app.
I followed the instructions from the example from here: http://code.google.com/mobile/ads/docs/ios/fundamentals.html
with the subtle difference that I created a method and I'm calling it from the viewDidLoad
The problem is that nothing is appearing, not even an empty frame. I also tried deleting everything except the main view from Interface Builder to make sure that is not behind something but nothing is appearing.
What can I've doing wrong?
Here's my method code:
- (void)showBanner {
// 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)];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = #"heresthestringofmyadmobid";
// 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_];
[self.view bringSubviewToFront:bannerView_];
// Initiate a generic request to load it with an ad.
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:
GAD_SIMULATOR_ID, // Simulator
#"heresthestringofmyphone", // Test iPhone 3Gs 4.3.1
nil];
[bannerView_ loadRequest:request];
}
I also tried harcoding the CGFrame with 0, 0, 320, 50 to make it appear on top but nothing happened either
Chompas,
You could not be getting a ad because of a low fill rate or other issue. To check if this is the issue, try enabling testMode so you will always get an ad.
You can do that with something like this:
GADRequest *request = [[GADRequest alloc] init];
request.testing = YES;
[bannerView_ loadRequest:request];
-David
.testing is now deprecated. You can instead use this:
#ifdef DEBUG
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:
GAD_SIMULATOR_ID,
#"YOUR_DEVICE_IDENTIFIER",
nil];
[bannerView_ loadRequest:request];
#else
[bannerView_ loadRequest:[GADRequest request]];
#endif
If you want test ads support in your real device and not just in the emulator, YOUR_DEVICE_IDENTIFIER should be replaced by your device identifier, which you can find while your device is connected under xCode menu > Window > Organizer > Devices. It's a long hex number.
I think you missed to set the delegate for processing events like ad recieved, ad failed, etc. I made the same mistake. [adView setDelegate: )]