Technical Note TN2286

Implementing a Shared iAd Banner

Why you should use a single shared iAd banner, and how to implement it in your application.

Introduction
Show and hide your iAd banner
Use a single shared iAd banner
Document Revision History

Introduction

There are two best practices you'll want to implement when integrating iAd into your iOS application. First, show and hide your iAd banner based on inventory availability; second, use a single shared iAd banner across multiple views. See the TabbedBanner sample code from iAdSuite and iAdSuite with Storyboards that demonstrates how to implement a shared iAd banner.

Show and hide your iAd banner

You should hide your iAd banner when ad inventory is unavailable. QA1641: Hiding iAd banners when ads are not available explains when and how you should hide the iAd banner.

Use a single shared iAd banner

Why use a shared banner

If your application has multiple tabs or views displaying an iAd banner, you should share a single instance of ADBannerView across each view.

Using a shared banner allows maximum efficiency in retrieving ad inventory for your app. The longest wait for iAd inventory is when the ADBannerView is instantiated. After that, ad inventory refreshes on a periodic basis. If you delete and recreate the ADBannerView every time the view switches, your wait for inventory is reset and induces a delay in waiting for another ad to become available.

How to implement a shared banner

  • Create an ADBannerView instance belonging to your app delegate soon after your application launches, for example, in -application:didFinishLaunchingWithOptions: of your app delegate.

  • Use your application delegate as the banner's delegate. Have your application delegate tell the current view controller if it should show or hide the banner. You can use UINavigationControllerDelegate or UITabBarControllerDelegate protocol to push the banner to show it.

  • Because the banner is owned by your app delegate, there is never a need to either release the banner, nor set its delegate to nil.



Document Revision History


DateNotes
2014-07-18

Fixed typo and added links to the iAdSuite and iAdSuite with Storyboard sample codes.

2011-09-07

New document that describes best practices for implementing a shared iAd banner across multiple views.