iAd未在用户设备上显示,但在我的Xcode部署设备上显示

时间:2015-11-17 09:54:06

标签: ios iad adbannerview

我制作了一个仅支持横向模式的应用程序,它包含一个iAd横幅。横幅在我的开发设备上显示得很好,横幅上写着“你已经连接到iAd网络”。

我的应用程序在App Store第一天收到大约100次下载,但没有收到一个iAd横幅请求。我从App Store下载了我的应用程序,但仍然收到“您已连接到iAd网络”消息。我从非开发设备下载了应用程序,iAd根本没有出现。

我的实施有问题吗?

·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");
}

1 个答案:

答案 0 :(得分:1)

在App Store上批准并发布您的应用程序后,iAd Network团队将对其进行审核。一旦他们批准,广告将被发送到您的应用程序。这有时可能需要7个工作日。

如果您在测试应用程序时收到蓝色您已连接到iAd 广告,那么您就可以去了。

Contact Us页面: (iAd App Network&gt;一般iAd App网络问题&gt;加入iAd App网络)

  

在您的应用获得批准并处于待售状态后,iAd也会对其进行审核,以确定应用是否适合接收来自iAd广告客户的广告。在您的应用获得iAd批准后,您可以开始为在您的应用中投放的广告赚取收入。