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



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

我的应用程序在应用商店的第一天就收到了大约100次下载,但没有一次iAd横幅请求。我从应用商店下载了我的应用程序,但仍然收到"你已连接到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");
}

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

如果您在测试应用程序时收到蓝色的"you are Connected To iAd"广告,那么您就可以继续了。


从"联系我们"页面:(iAd应用网络>一般iAd应用程序网络问题>加入iAd应用软件网络)

在您的应用程序获得批准并处于准备销售状态后,iAd还将对其进行审查,以确定该应用程序是否适合接收iAd广告商的广告。在你的应用程序获得iAd批准后,你可以开始为应用程序中运行的广告赚取收入。

最新更新