I made an application that only supports landscape mode and it includes an iAd banner. The banner is showing on my development device just fine, banner with message "You're connected to iAd network".
My application received around 100 downloads its first day on the App Store but not one iAd banner request. I downloaded my application from the App Store and still received the "You're connected to iAd network" message. I downloaded the application from a non development device and iAd does not appear at all.
Is there an issue with my implementation?
.h
#import <iAd/iAd.h>
@interface `enter code here`ViewController : UIViewController <UIAlertViewDelegate,MFMailComposeViewControllerDelegate,ADBannerViewDelegate>
{
BOOL _bannerIsVisible;
ADBannerView *_adBanner;
.m
- (void)iAdInit:(BOOL) isInit {
int width;
int height;
if([[NSUserDefaults standardUserDefaults] integerForKey:@"removeAd"]!=1)
{
if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
width=1024;
height=66;
}
else//iphone or ipad
{
width=480;
height=32;
}
if(isInit)
{
_adBanner = [[ADBannerView alloc] init];
_adBanner.delegate = self;
[_adBanner setFrame:CGRectMake(0, self.view.frame.size.height, width,height)];
}
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self iAdInit:1];
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
NSLog(@"Load AD");
if (!_bannerIsVisible)
{
// If banner isn't part of view hierarchy, add it
if (_adBanner.superview == nil)
{
[self.view addSubview:_adBanner];
}
banner.hidden=NO;
[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
// Assumes the banner view is just off the bottom of the screen.
banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);
[self moveOverBannerElements:-banner.frame.size.height];
[UIView commitAnimations];
_bannerIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
NSLog(@"Can't Load AD");
if (_bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// Assumes the banner view is placed at the bottom of the screen.
banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[self moveOverBannerElements:banner.frame.size.height];
[UIView commitAnimations];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
banner.hidden=YES;
});
_bannerIsVisible = NO;
}
}
NSLayoutConstraint *constraint;
NSLayoutConstraint *constraint2;
-(void)moveOverBannerElements:(float) offsetYPosition {
if(constraint){[self.view removeConstraint: constraint];}
if(constraint2){[self.view removeConstraint: constraint2];}
if(offsetYPosition<0){
constraint = [NSLayoutConstraint constraintWithItem:resolutionSegment attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0f constant:offsetYPosition-4];
[self.view addConstraint:constraint];
constraint2 = [NSLayoutConstraint constraintWithItem:fpsSegment attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0f constant:offsetYPosition-4];
[self.view addConstraint:constraint2];
}
}
-(void) removeAd {
[[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"removeAd"];
[[NSUserDefaults standardUserDefaults] synchronize];
///return elements to defaul position
if(constraint){[self.view removeConstraint: constraint];}
if(constraint2){[self.view removeConstraint: constraint2];}
///return elements to defaul position
_adBanner.hidden=YES;
NSLog(@"remove ad");
}