I want to add iAd in my app. And i have done lot of research and seen video that display how to add iAd in your project. But all video and tutorial display code for adding iAd in project none of them said any thing about if we have to do something in iTunes connect or not.
I have seen this link in apple doc. which is nice to add iAd. and in that link it will display tab iTunes Connect Developer Guide
which display some setting we do have to make in iTunes connect to add iAd in app.
So as my understanding we have to first do that setting in iTunes connect account for iAd and then implement code to add iAd in project.
But i m confuse at this line in apple doc After you have enabled at least one app for iAd ads, you see the iAd Network module on your iTunes Connect homepage.
What does it mean that enable app for iAd?
itunesconnect -> manage your apps
and this code Display the Default Screen of iAd network
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface iAdExViewController : UIViewController <ADBannerViewDelegate>
{
ADBannerView *adView;
BOOL bannerIsVisible;
}
@property (nonatomic,assign) BOOL bannerIsVisible;
@end
Then modify viewDidLoad
method in iAdExViewController.m
- (void)viewDidLoad
{
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, -50);
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
[self.view addSubview:adView];
adView.delegate=self;
self.bannerIsVisible=NO;
[super viewDidLoad];
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
// banner is invisible now and moved out of the screen on 50 px
banner.frame = CGRectOffset(banner.frame, 0, 50);
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// banner is visible and we move it out of the screen, due to connection issue
banner.frame = CGRectOffset(banner.frame, 0, -50);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
NSLog(@"Banner view is beginning an ad action");
BOOL shouldExecuteAction = YES;
if (!willLeave && shouldExecuteAction)
{
// stop all interactive processes in the app
// [video pause];
// [audio pause];
}
return shouldExecuteAction;
}
- (void)bannerViewActionDidFinish:(ADBannerView *)banner
{
// resume everything you've stopped
// [video resume];
// [audio resume];
}