iAd

気付いている人も居ると思いますが、8月末から日本でもiAdのサービスが始まりました。FuturesVisionのぽけっと定規にも 1.2 から広告を入れさせて頂いています。
実は 1.1 から iAd 単独の広告を入れていたのですが、その時点では日本でサービスが始まっておらず、殆ど意味がありませんでした。(もちろんUS等でダウンロードして頂いた方々からのアクセスはありました)

今は#ifdefで実装されていませんが、ソースの中に残っているiAdの実装部分をご紹介します。一応、AppleのReviewも通過したソースです。
これをRootViewControllerの中で実装し、- (void)viewDidLoad の中で

[self addBarInit];

を呼び出してやるだけです。



-(void)adBarInit {
CGRect r;
CGFloat tabBarHeight;
UIDevice *device;
NSString *ver;

bannerIsVisible = NO;
device = [UIDevice currentDevice];
ver = [device systemVersion];

if([ver compare: @”4.0.0″] == NSOrderedAscending) {
return;
}

adView = [[ADBannerView alloc] initWithFrame: CGRectZero];
adView.alpha = 0.5f;
adView.delegate = self;
if([ver compare: @”4.1.9″] == NSOrderedDescending) {
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierLandscape];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
}
else {
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier480x32];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier480x32;
}

tabBarHeight = 49;

r = adView.frame;
r.origin.y = self.view.frame.size.width- tabBarHeight – adView.frame.size.height;

if([ver compare: @”4.1.9″] == NSOrderedAscending) {
r.origin.y -= 8;
}
adView.frame = r;

device = nil;
ver = nil;

[self.rulerView addSubview: adView];
[self.rulerView bringSubviewToFront:adView];
}

– (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
if(bannerIsVisible) {
[UIView beginAnimations:@”animateAdBannerOff” context:nil];

[UIView commitAnimations];
bannerIsVisible = NO;
}
}

– (void)bannerViewDidLoadAd:(ADBannerView *)banner {
if(!bannerIsVisible) {
if(activeView == nil) {
activeView = self.rulerView;
[activeView addSubview: adView];
[activeView bringSubviewToFront:adView];
}
[UIView beginAnimations:@”animateAdBannerOn” context:nil];
[UIView commitAnimations];
bannerIsVisible = YES;
banner.hidden = NO;
[banner setNeedsDisplay];
}
}


忘却とは恐ろしい物で、コレで全部か?と言われると…な状況ですがご参考にはなると思います。

サービスが始まったとは言え、まだまだiAdがヒットする確率は低いようです。私もまだ1度しか見た事がありません。
ですがiAdに限らず広告を入れると、ダウンロードされた自分のアプリがどの程度実際に利用されているのかが分かるので、参考になります。
ダウンロードされても実際に使って頂かなければ寂しいですもんね。

最後に、ぽけっと定規は無料のアプリですので、出来ればたまに広告をクリックして頂けると助かります。
また、有料ではありますが広告無しのぽけっと定規プラスもありますので、よろしければそちらもご利用ください。

次回はぽけっと定規 1.2で実装したAdWhirlについて書いてみたいと思います。

Leave a Reply

Your email address will not be published. Required fields are marked *

*

CAPTCHA


WP-SpamFree by Pole Position Marketing