ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Create a Mobile Advertising iOS iAd App

Updated on November 14, 2012
klanguedoc profile image

Kevin is Software Developer with 20 years experience designing and building software applications including iOS and Android apps.


(c) 2012 kevin languedoc (klanguedoc)

iAd represents an attractive way to generate income from mobile advertising, hence monetize an iOS iPhone or iPad mobile app. Several hundred developers are generating in the tens of thousands of dollars using this online marketing method which can include small banner ads, full page advertisements or in app purchases. Using the free iAd mobile advertising network from Apple provides a way to offer your iOS app for free but still generate an income. Apple has relationships with all the top brands and advertising agencies so you are insured to have high quality ads from premier corporations.


This guide will provide a high level overview of the iAd API and network, where the network is available and how to setup or enable the iAd network in your applications on the iTunesConnect portal. The guide will also provide a sample app to demonstrate how easy it is to add iAd to your existing or new applications with very little code.

Creating applications for the iPhone, iPad (full size or mini) or iPod Touch that uses the iAd mobile advertising network is an easy process that can be broken down into two large parts. You can to configure your Developer account to use iAds and you have to create an app that implements the ADBannerView and the ADBannerViewDelegate. This guide will provide instructions on both of the steps and provide an ADBannerView and ADBannerViewDelegate examples to show you how to make a mobile application for iPhone, iPad or iPod Touch. The Apple iAd Network in available in these following countries:

United States
United Kingdom

iAd iPhone App Demo

Join iAd Network

The first step to complete to be able to participate in the iAd mobile advertising program is to join the iAd Network through iTunes Connect. Of course you need to be a member of the Apple iOS Developer Program, which cost $99 at the time of this writing. Navigate to the iTunes Portal and login. Then click on the Contracts, Tax, and Banking link. Under the Master Agreements section, you will find the iAd Network setup options. If you haven’t already so, you will need to provide your banking and tax information if you are selling in the United States or other host country, you will need to get your proper tax numbers and fill in the appropriate forms.

You will need to do this configuration to get paid the advertisement revenue that is generated by ads in your apps. Once this is done, you will need to set the preferences and configure iAd in your app.

Manage Your Applications

Again in iTunesConnect, select the “Manage your applications” section and either select an existing app to add iAd to or create a new application profile. Depending on the option you will chose, once the application is created, click on the “Setup iAds” and in the following page ndicate it the app is targeted for users under the age of 17 and click on the “Enable iAds” button. Click on the “Save” button to save your configuration. Next we will create a sample app to test the iAd configuration.

The iAd API

The iAd framework has four classes which are listed here:

  1. ADBannerView
  2. ADInterstitialAd
  3. ADBannerViewDelegate
  4. ADInterstitialAdDelegate

The ADBannerView adds a view to the application to display ads to the user when the app is running on the iPhone, iPad or iPod Touch device. If the user clicks on the ad in the view an action will be triggered and is enabled in the advertisement. The view’s delegate is triggered to cycle through the available ads. The app needs an active Internet connection for this to work, otherwise, view should not display any ads.

The ADInterstitialAd class displays full page advertisement on iPad devices. When the user triggers the ad, a full page ad with its associated rich media is launched, inviting the user to interact with it. Revenue is generated when the user interacts with the ad or view the ad.

If added to the header file that implements the ADBannerView, the ADBannerViewDelegate enables the interactivity of the ADBannerView. the delegate is called when an ad is loaded, thus allowing the user to interact with it.

The ADInterstitialAdDelegate is called when the user interacts with the full page ad in the iPad app when the delegate is added to the header file that implements the ADInterstitialAd class.

UIView as an ADBannerView
UIView as an ADBannerView | Source

Develop Sample iAd App

To demonstrate how easy it is to add iAd functionality to an app, I create a Single-View application to show the basic steps to develop an iAd mobile application.

From the Xcode IDE create a Single-View application. With the application created and loaded in Xcode, select the project root in the project navigator and scroll down to the Linked Libraries and Frameworks section under the Summary page in the right side pane. Click on the “+” button and search for the “iAd” framework and click “Add” to add the framework to your project

Open the storyboard following the addition of the iAd framework and add a UIView to display and interact with iAd network. When adding an UIView I find it useful to stagger it on the previous UIView so as not occupy the full space of the Scene automatically. The screenshot provides a visual aid to help you better understand. Use the handles on the UIView to shrink the width and height of the UIView enough so that it fits within the confines of the Scene.

Set the size and position of the UIView from the Size inspector: x:160, y:25, width:320 height:50. This will position the UIView at the top of the Scene as in the following screenshot. With UIView selected, select the ADBannerView class from the list of available custom class in the Identity inspector in Xcode.

Also open the Editor Assistant (it is the tuxedo icon in the toolbar) and drag a connection (ctrl+drag) from the UIView to the header file to create an IBOutlet. Name the IBOutlet whatever you want so long as you use that value in the code later. For this example, I am naming the IBOutlet: adBannerview.

Close the Editor assistant and open the ViewController header file directly. Import the iAd framework using the import statement and add an instance property for an ADBannerView: adBanner. This object will be added to the UIView that was previously created in the Storyboard.

To be able to interact with the ADBannerView, you will need to implement the ADBannerViewDelegate and its required properties: requiredContentSizeIdentifiers, currentContentSizeIdentifier and sizeFromBannerContentSizeIdentifier, bannerViewActionInProgress as in the following code listing.

In the implementation, add an init method to iniliaze the ADBannerView and the UIView. It is in this method that the adBanner object’s delegate is set. In the viewDidLoad method, the adBanner object is added to the adBannerview after it is initialized and the dimensions are set using the requiredContentSizeIdentifiers and its corresponding properties: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape.

The other methods are not needed for this simple example. If you run the app as in the followoing video, you will see the richness of the api without additional programming.


//  ViewController.h
//  MobileAds
//  Created by Kevin Languedoc on 11/1/12.
//  Copyright (c) 2012 Kevin Languedoc. All rights reserved.

#import <UIKit/UIKit.h>
#import <iAd/iAd.h>

@interface ViewController : UIViewController<ADBannerViewDelegate>

@property (strong, nonatomic) IBOutlet UIView *adBannerView;
@property (nonatomic, strong) ADBannerView *adBanner;

- (void) bannerViewDidLoadAd;
- (void)bannerViewWillLoadAd:(ADBannerView *)banner;
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error;


//  ViewController.m
//  MobileAds
//  Created by Kevin Languedoc on 11/1/12.
//  Copyright (c) 2012 Kevin Languedoc. All rights reserved.

#import "ViewController.h"

@interface ViewController ()


@implementation ViewController
@synthesize adBannerView;
@synthesize adBanner;

- (void)viewDidLoad
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    adBanner = [[ADBannerView alloc]initWithFrame:CGRectZero];
    adBanner.requiredContentSizeIdentifiers =
    [NSSet setWithObjects:
     ADBannerContentSizeIdentifierLandscape, nil];
    adBanner.delegate = self;
    CGRect contentFrame = self.view.bounds;
    if (contentFrame.size.width < contentFrame.size.height) {
        adBanner.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
    } else {
        adBanner.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
    CGRect bannerFrame = adBanner.frame;
    if (adBanner.bannerLoaded) {
        contentFrame.size.height -= adBanner.frame.size.height;
        bannerFrame.origin.y = contentFrame.size.height;
    } else {
        bannerFrame.origin.y = contentFrame.size.height;

- (void)viewDidUnload
    [self setAdBannerView:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    return YES;
- (void) bannerViewDidLoadAd{
- (void)bannerViewWillLoadAd:(ADBannerView *)banner{
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{


    0 of 8192 characters used
    Post Comment

    No comments yet.


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)