Add iAD on your app

by Deepak Dhakal 29. February 2012 11:39

Here is a step by step as I did it.

1. You need to enable iAd Network in your ituneconnect account :-
a) Make sure your iAd Contract is in effect.
b) Add a new app or if you are adding iAd to existing app, click on add version.
Then on that version, Enable the iAd for that app.
c) You may need to wait a while, then when you go to your iTunesconnect home page, you will see a new module "iAd Network" on the right column. Click that and follow the instructions.

2. Then just go to your XCode, add iAds thingies:-
a) Add Existing Framework - > iAd.framework.
b) In your .h add #import <iAd/iAd.h>
c) In your .h, add <ADBannerViewDelegate>
d) Create IBOutlet for the ADBannerView, drop the iAd object in your IB and
link it to the IBOutlet
e) Put all of the 4 delegates in your code. You need to show the ADBanner when an ad is called by the delegate. And when the delegate says there are no ads or error (due to no internet connection), you need to hide the AD.

This is my code:

- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave {
	return YES;

- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
	AdIsShowing = YES;
	if (myAD.center.y>500) {
		[self moveAdIn]; // this is a custom method to show ad and move things around.

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
	AdIsShowing = NO;
	if (myAD.center.y<460) {
	[self moveAdOut]; // this is a custom method to show ad and move things around.

-(void)bannerViewActionDidFinish:(ADBannerView *)banner

Done. When you run, you should see the iAd Test Advertisment.


There is youtube video that explains in detail as well.


Tags: , ,


Powered by BlogEngine.NET
Original Design by Laptop Geek, Adapted by onesoft