user3423384
user3423384

Reputation: 697

Admobs ad only shows on the simulator

I've having issues with creating an admob ad which will be shown on the simulator and the device. At the moment i't will only show on the simulator. Here i get an ad which say: PUBLISHER TEST AD.

I've searched for sometime, but cant find an solution

Why wont it show on the device as well?

- (void)viewDidLoad

{
self.bannerView = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height-50, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height)];

self.bannerView.adUnitID = myAdUnitID;
self.bannerView.delegate = self;
[self.bannerView setRootViewController:self];
[self.view addSubview:self.bannerView];
[self.bannerView loadRequest:[self createRequest]];


[self.navigationController.tabBarController.tabBar setHidden:YES];

}

-(GADRequest *)createRequest {
     GADRequest *request = [GADRequest request];
     request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];
     return request;
 }

 -(void)adViewDidReceiveAd:(GADBannerView *)adView {
     NSLog(@"Ad Received");
     [UIView animateWithDuration:1.0 animations:^{

         adView.frame = CGRectMake(0.0, self.view.frame.size.height-50, adView.frame.size.width, adView.frame.size.height);


     }];

 }


 -(void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error {
     NSLog(@"error due to: %@", [error localizedFailureReason]);
 }

Upvotes: 1

Views: 648

Answers (1)

Buntylm
Buntylm

Reputation: 7373

Admobs ad only shows on the simulator

Because You Added GAD_SIMULATOR_ID in this line of code so it showing only testing ads on simulator.

[NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];

So my opinion is you can test on device as if you add your device id in this array.So every time when you open this app this will show you test add and as soon possible if add available on Google Admob this will show you the ad and start showing Impression on your Admob account.

Upvotes: 1

Related Questions